Re: Macnetworkprog Digest, Vol 1, Issue 74
Re: Macnetworkprog Digest, Vol 1, Issue 74
- Subject: Re: Macnetworkprog Digest, Vol 1, Issue 74
- From: Frederick Cheung <email@hidden>
- Date: Thu, 16 Dec 2004 20:52:30 +0000
On 16 Dec 2004, at 20:45, Ryan M Joseph wrote:
I unfortunately don't understand much about addresses besides IPs and
even then not much. The problem still remains I don't know enough
about the protocol to fill in the fields properly. For example the IP
128.0.0.0, how can I describe THAT with the sockaddr. Is there a
reference location of this information or a function that could
convert an IP into a sockaddr (like OT maybe)? My real issue I think
is not knowing the low-level interpretation of IPs. Thanks again.
Instead of using a sockaddr, use a sockaddr_in, which is defined as
struct sockaddr_in {
u_char sin_len;
u_char sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
You want length to be the size of the struct, family to be AF_INET, you
set port to the port you want, and sin_addr to the ip address.
sin_addr is just a struct containing a 32 bit integer (it's only a
struct for historical reason), defined in the obvious way (ie for
11.22.33.44 the first byte (in big endian order )contains 11, the
second 22 and so on)
Fred
sockaddr is a generic thingy, that allows a single set of function to
calls to work with different types of address (ipv4, ipv6, other
stuff).
Various protocols give different meaning to the bytes that follow the
sin_length and sin_family fields, for ipv4 stuff this is defined by
the sockaddr_in structure.
Fred
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden