//
///include/bits/sockaddr.h
1 /* Definition of `struct sockaddr_*' common members. Generic/4.2 BSD version*/
19
20 /*
21 * Never include this file directly; use <sys/socket.h> instead.
22 */
23
24 #ifndef _BITS_SOCKADDR_H
25 #define _BITS_SOCKADDR_H 1
26
27
28 /* POSIX.1g specifies this type name for the `sa_family' member. */
29 typedef unsigned short int sa_family_t;
30
31 /* This macro is used to declare the initial common members
32 of the data types used for socket addresses, `struct sockaddr',
33 `struct sockaddr_in', `struct sockaddr_un', etc. */
34
35 #define __SOCKADDR_COMMON(sa_prefix) /
36 sa_family_t sa_prefix##family
37
38 #define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int))
39
40 #endif /* bits/sockaddr.h */
//
//include/bits/socket.h
21 #ifndef __BITS_SOCKET_H
22 #define __BITS_SOCKET_H
23
24 #ifndef _SYS_SOCKET_H
25 # error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
26 #endif
27
28 #define __need_size_t
29 #include <stddef.h>
30
31 #include <sys/types.h>
32
33 /* Type for length arguments in socket calls. */
34 #ifndef __socklen_t_defined
35 typedef __socklen_t socklen_t;
36 # define __socklen_t_defined
37 #endif
38
39 /* Types of sockets. 套接字类型*/
40 enum __socket_type
41 {
42 SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
43 byte streams. */
44 #define SOCK_STREAM SOCK_STREAM
45 SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
46 of fixed maximum length. */
47 #define SOCK_DGRAM SOCK_DGRAM
48 SOCK_RAW = 3, /* Raw protocol interface. */
49 #define SOCK_RAW SOCK_RAW
50 SOCK_RDM = 4, /* Reliably-delivered messages. */
51 #define SOCK_RDM SOCK_RDM
52 SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
53 datagrams of fixed maximum length. */
54 #define SOCK_SEQPACKET SOCK_SEQPACKET
55 SOCK_DCCP = 6, /* Datagram Congestion Control Protocol. */
56 #define SOCK_DCCP SOCK_DCCP
57 SOCK_PACKET = 10, /* Linux specific way of getting packets
58 at the dev level. For writing rarp and
59 other similar things on the user level. */
60 #define SOCK_PACKET SOCK_PACKET
61
62 /* Flags to be ORed into the type parameter of socket and socketpair and
63 used for the flags parameter of paccept. */
64
65 SOCK_CLOEXEC = 02000000, /* Atomically set close-on-exec flag for the
66 new descriptor(s). */
67 #define SOCK_CLOEXEC SOCK_CLOEXEC
68 SOCK_NONBLOCK = 04000 /* Atomically mark descriptor(s) as
69 non-blocking. */
70 #define SOCK_NONBLOCK SOCK_NONBLOCK
71 };
72
73 /* Protocol families. 协议家族 */
74 #define PF_UNSPEC 0 /* Unspecified. */
75 #define PF_LOCAL 1 /* Local to host (pipes and file-domain). */
76 #define PF_UNIX PF_LOCAL /* POSIX name for PF_LOCAL. */
77 #define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */
78 #define PF_INET 2 /* IP protocol family. */
108 /* Address families. 地址家族,由协议家族决定 */
109 #define AF_UNSPEC PF_UNSPEC
110 #define AF_LOCAL PF_LOCAL
111 #define AF_UNIX PF_UNIX
112 #define AF_FILE PF_FILE
113 #define AF_INET PF_INET
158 /* Get the definition of the macro to define the common sockaddr members. */
159 #include <bits/sockaddr.h>
160
161 /* Structure describing a generic socket address. */
162 struct sockaddr
163 {
164 __SOCKADDR_COMMON (sa_); /* Common data: address family and length. 这里引用了bit
glibc之socket网络编程
最新推荐文章于 2023-09-08 10:45:38 发布