6 #include <linux/socket.h>
8 #ifdef _MIT_POSIX_THREADS
9 #include <pthread/mit/posix.h>
14 /* struct msghdr is not defined in linux 1.2. This will allow sendmsg
15 and recvmsg in libc 5.2.9 to compile under 1.2.x and shouldn't cause
16 any problem for 1.3.x */
19 /* Create a new socket of type TYPE in domain DOMAIN, using
20 protocol PROTOCOL. If PROTOCOL is zero, one is chosen
21 automatically. Returns a file descriptor for the new socket,
23 int socket __P ((int __family, int __type, int __protocol));
25 /* Create two new sockets, of type TYPE in domain DOMAIN and using
26 protocol PROTOCOL, which are connected to each other, and put file
27 descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero,
28 one will be chosen automatically. Returns 0 on success, -1
30 int socketpair __P ((int __family, int __type, int __protocol,
33 /* Give the socket FD the local address ADDR (which is LEN bytes
35 int bind __P ((int __sockfd, __const struct sockaddr *__my_addr,
38 /* Open a connection on socket FD to peer at ADDR (which LEN bytes
39 long). For connectionless socket types, just set the default
40 address to send to and the only address from which to accept
41 transmissions. Return 0 on success, -1 for errors. */
42 int connect __P ((int __sockfd, __const struct sockaddr *__serv_addr,
45 /* Prepare to accept connections on socket FD.
46 N connection requests will be queued before further requests are
47 refused. Returns 0 on success, -1 for errors. */
48 int listen __P ((int __sockfd, int __n));
50 /* Await a connection on socket FD.
51 When a connection arrives, open a new socket to communicate with it,
52 set *ADDR (which is *ADDR_LEN bytes long) to the address of the
53 connecting peer and *ADDR_LEN to the address's actual length, and
54 return the new socket's descriptor, or -1 for errors. */
55 int accept __P ((int __sockfd, __const struct sockaddr *__peer,
58 /* Put the current value for socket FD's option OPTNAME at protocol
59 level LEVEL into OPTVAL (which is *OPTLEN bytes long), and set
60 *OPTLEN to the value's actual length. Returns 0 on success, -1 for
62 int getsockopt __P ((int __s, int __level, int __optname,
63 void *__optval, int *__optlen));
65 /* Set socket FD's option OPTNAME at protocol level LEVEL
66 to *OPTVAL (which is OPTLEN bytes long).
67 Returns 0 on success, -1 for errors. */
68 int setsockopt __P ((int __s, int __level, int __optname,
69 __const void *__optval, int optlen));
71 /* Put the local address of FD into *ADDR and its length in *LEN. */
72 int getsockname __P ((int __sockfd, struct sockaddr *__addr,
75 /* Put the address of the peer connected to socket FD into *ADDR
76 (which is *LEN bytes long), and its actual length into *LEN. */
77 int getpeername __P ((int __sockfd, struct sockaddr *__peer,
80 /* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
81 int send __P ((int __sockfd, __const void *__buff, size_t __len,
82 unsigned int __flags));
84 /* Read N bytes into BUF from socket FD.
85 Returns the number read or -1 for errors. */
86 int recv __P ((int __sockfd, void *__buff, size_t __len,
87 unsigned int __flags));
89 /* Send N bytes of BUF on socket FD to peer at address ADDR (which is
90 ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
91 int sendto __P ((int __sockfd, __const void *__buff, size_t __len,
92 unsigned int __flags, __const struct sockaddr *__to,
95 /* Read N bytes into BUF through socket FD.
96 If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address
97 of the sender, and store the actual size of the address in
98 *ADDR_LEN. Returns the number of bytes read or -1 for errors. */
99 int recvfrom __P ((int __sockfd, void *__buff, size_t __len,
100 unsigned int __flags, struct sockaddr *__from,
103 /* Send a message described MESSAGE on socket FD.
104 Returns the number of bytes sent, or -1 for errors. */
105 extern int sendmsg __P ((int __fd, __const struct msghdr *__message,
106 unsigned int __flags));
108 /* Receive a message as described by MESSAGE from socket FD.
109 Returns the number of bytes read or -1 for errors. */
110 extern int recvmsg __P ((int __fd, struct msghdr *__message,
111 unsigned int __flags));
113 /* Shut down all or part of the connection open on socket FD.
114 HOW determines what to shut down:
115 0 = No more receptions;
116 1 = No more transmissions;
117 2 = No more receptions or transmissions.
118 Returns 0 on success, -1 for errors. */
119 int shutdown __P ((int __sockfd, int __how));
122 /* belongs here or elsewhere? */
123 int rcmd __P ((char **__ahost, unsigned short __inport,
124 __const char *__locuser, __const char *__remuser,
125 __const char *__cmd, int *__fd2p));
126 int rresvport __P ((int *__port));
127 int ruserok __P ((__const char *__rhost, int __superuser,
128 __const char *__ruser, __const char *__luser));
129 int rexec __P ((char **__ahost, int __inport, __const char *__user,
130 __const char *__passwd, __const char *__cmd,
135 #endif /* _SYS_SOCKET_H */