Difference between revisions of "Socket structs"
From Ilianko
Line 1: | Line 1: | ||
== addrinfo == | == addrinfo == | ||
+ | <code><pre> | ||
----------- | ----------- | ||
addrinfo | addrinfo | ||
Line 7: | Line 8: | ||
sockaddr | sockaddr | ||
| | | | ||
− | + | </pre></code> | |
<code><pre> | <code><pre> | ||
Line 23: | Line 24: | ||
</pre></code> | </pre></code> | ||
+ | == Адреси == | ||
<code><pre> | <code><pre> | ||
struct sockaddr { | struct sockaddr { | ||
Line 30: | Line 32: | ||
</pre></code> | </pre></code> | ||
+ | или | ||
+ | |||
+ | <code><pre> | ||
+ | struct sockaddr_in { | ||
+ | short int sin_family; // Address family, AF_INET | ||
+ | unsigned short int sin_port; // Port number | ||
+ | struct in_addr sin_addr; // Internet address | ||
+ | unsigned char sin_zero[8]; // Same size as struct sockaddr | ||
+ | }; | ||
+ | </pre></code> | ||
[[Category:sockets]] | [[Category:sockets]] |
Revision as of 13:48, 12 April 2013
addrinfo
-----------
addrinfo
-----------
|
sockaddr
|
struct addrinfo
{
int ai_flags; // AI_PASSIVE, AI_CANONNAME, etc.
int ai_family; // AF_INET, AF_INET6, AF_UNSPEC
int ai_socktype; // SOCK_STREAM, SOCK_DGRAM
int ai_protocol; // use 0 for "any"
size_t ai_addrlen; // size of ai_addr in bytes
struct sockaddr *ai_addr; // struct sockaddr_in or _in6
char *ai_canonname; // full canonical hostname
struct addrinfo *ai_next; // linked list, next node
};
Адреси
struct sockaddr {
unsigned short sa_family; // address family, AF_xxx
char sa_data[14]; // 14 bytes of protocol address
};
или
struct sockaddr_in {
short int sin_family; // Address family, AF_INET
unsigned short int sin_port; // Port number
struct in_addr sin_addr; // Internet address
unsigned char sin_zero[8]; // Same size as struct sockaddr
};