]> sourceware.org Git - glibc.git/blob - include/sys/socket.h
Update.
[glibc.git] / include / sys / socket.h
1 #ifndef _SYS_SOCKET_H
2 #include <socket/sys/socket.h>
3
4 /* Now define the internal interfaces. */
5
6 /* Create a new socket of type TYPE in domain DOMAIN, using
7 protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically.
8 Returns a file descriptor for the new socket, or -1 for errors. */
9 extern int __socket (int __domain, int __type,
10 int __protocol) attribute_hidden;
11
12 /* Create two new sockets, of type TYPE in domain DOMAIN and using
13 protocol PROTOCOL, which are connected to each other, and put file
14 descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero,
15 one will be chosen automatically. Returns 0 on success, -1 for errors. */
16 extern int __socketpair (int __domain, int __type, int __protocol,
17 int __fds[2]) attribute_hidden;
18
19 /* Return a socket of any type. The socket can be used in subsequent
20 ioctl calls to talk to the kernel. */
21 extern int __opensock (void) internal_function attribute_hidden;
22
23 /* Put the address of the peer connected to socket FD into *ADDR
24 (which is *LEN bytes long), and its actual length into *LEN. */
25 extern int __getpeername (int __fd, __SOCKADDR_ARG __addr,
26 socklen_t *__len) attribute_hidden;
27
28 /* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
29 extern ssize_t __libc_send (int __fd, __const void *__buf, size_t __n,
30 int __flags);
31 extern ssize_t __send (int __fd, __const void *__buf, size_t __n, int __flags);
32 libc_hidden_proto (__send)
33
34 /* Read N bytes into BUF from socket FD.
35 Returns the number read or -1 for errors. */
36 extern ssize_t __libc_recv (int __fd, void *__buf, size_t __n, int __flags);
37
38 /* Send N bytes of BUF on socket FD to peer at address ADDR (which is
39 ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
40 extern ssize_t __libc_sendto (int __fd, __const void *__buf, size_t __n,
41 int __flags, __CONST_SOCKADDR_ARG __addr,
42 socklen_t __addr_len);
43
44 /* Read N bytes into BUF through socket FD.
45 If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
46 the sender, and store the actual size of the address in *ADDR_LEN.
47 Returns the number of bytes read or -1 for errors. */
48 extern ssize_t __libc_recvfrom (int __fd, void *__restrict __buf, size_t __n,
49 int __flags, __SOCKADDR_ARG __addr,
50 socklen_t *__restrict __addr_len);
51
52 /* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
53 For connectionless socket types, just set the default address to send to
54 and the only address from which to accept transmissions.
55 Return 0 on success, -1 for errors. */
56 extern int __libc_connect (int __fd, __CONST_SOCKADDR_ARG __addr,
57 socklen_t __len);
58 extern int __connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
59 extern int __connect_internal (int __fd, __CONST_SOCKADDR_ARG __addr,
60 socklen_t __len) attribute_hidden;
61
62 /* Send N bytes of BUF on socket FD to peer at address ADDR (which is
63 ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
64 extern ssize_t __libc_sendto (int __fd, __const void *__buf, size_t __n,
65 int __flags, __CONST_SOCKADDR_ARG __addr,
66 socklen_t __addr_len);
67 extern ssize_t __sendto (int __fd, __const void *__buf, size_t __n,
68 int __flags, __CONST_SOCKADDR_ARG __addr,
69 socklen_t __addr_len) attribute_hidden;
70
71 /* Read N bytes into BUF through socket FD.
72 If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
73 the sender, and store the actual size of the address in *ADDR_LEN.
74 Returns the number of bytes read or -1 for errors. */
75 extern ssize_t __recvfrom (int __fd, void *__restrict __buf, size_t __n,
76 int __flags, __SOCKADDR_ARG __addr,
77 socklen_t *__restrict __addr_len) attribute_hidden;
78
79 /* Send a message described MESSAGE on socket FD.
80 Returns the number of bytes sent, or -1 for errors. */
81 extern ssize_t __libc_sendmsg (int __fd, __const struct msghdr *__message,
82 int __flags);
83 extern ssize_t __sendmsg (int __fd, __const struct msghdr *__message,
84 int __flags) attribute_hidden;
85
86 /* Receive a message as described by MESSAGE from socket FD.
87 Returns the number of bytes read or -1 for errors. */
88 extern ssize_t __libc_recvmsg (int __fd, struct msghdr *__message,
89 int __flags);
90 extern ssize_t __recvmsg (int __fd, struct msghdr *__message,
91 int __flags) attribute_hidden;
92
93 /* Set socket FD's option OPTNAME at protocol level LEVEL
94 to *OPTVAL (which is OPTLEN bytes long).
95 Returns 0 on success, -1 for errors. */
96 extern int __setsockopt (int __fd, int __level, int __optname,
97 __const void *__optval,
98 socklen_t __optlen) attribute_hidden;
99
100 /* Put the local address of FD into *ADDR and its length in *LEN. */
101 extern int __getsockname (int __fd, __SOCKADDR_ARG __addr,
102 socklen_t *__restrict __len) attribute_hidden;
103
104 /* Give the socket FD the local address ADDR (which is LEN bytes long). */
105 extern int __bind (int __fd, __CONST_SOCKADDR_ARG __addr,
106 socklen_t __len) attribute_hidden;
107
108 /* Prepare to accept connections on socket FD.
109 N connection requests will be queued before further requests are refused.
110 Returns 0 on success, -1 for errors. */
111 extern int __listen (int __fd, int __n) attribute_hidden;
112
113 /* Await a connection on socket FD.
114 When a connection arrives, open a new socket to communicate with it,
115 set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting
116 peer and *ADDR_LEN to the address's actual length, and return the
117 new socket's descriptor, or -1 for errors. */
118 extern int __libc_accept (int __fd, __SOCKADDR_ARG __addr,
119 socklen_t *__restrict __addr_len)
120 __THROW;
121
122 /* Return the length of a `sockaddr' structure. */
123 #ifdef _HAVE_SA_LEN
124 # define SA_LEN(_x) (_x)->sa_len
125 #else
126 extern int __libc_sa_len (sa_family_t __af);
127 extern int __libc_sa_len_internal (sa_family_t __af) attribute_hidden;
128 # ifndef NOT_IN_libc
129 # define SA_LEN(_x) INTUSE(__libc_sa_len)((_x)->sa_family)
130 # else
131 # define SA_LEN(_x) __libc_sa_len((_x)->sa_family)
132 # endif
133 #endif
134
135
136 #ifndef NOT_IN_libc
137 # define __connect(fd, addr, len) INTUSE(__connect) (fd, addr, len)
138 #endif
139
140 #endif
This page took 0.044353 seconds and 5 git commands to generate.