etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / listen.c
bloba2522af906f05d1938403f57004d5fb934b00c78
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
5 #include <errno.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <sys/ioctl.h>
9 #include <sys/socket.h>
10 #include <netinet/in.h>
12 #include <net/gen/in.h>
13 #include <net/gen/tcp.h>
14 #include <net/gen/tcp_io.h>
15 #include <net/gen/udp.h>
16 #include <net/gen/udp_io.h>
19 * Put a socket in listening mode.
21 static int
22 __listen(int fd, int backlog)
24 message m;
26 memset(&m, 0, sizeof(m));
27 m.m_lc_vfs_listen.fd = fd;
28 m.m_lc_vfs_listen.backlog = backlog;
30 return _syscall(VFS_PROC_NR, VFS_LISTEN, &m);
33 int listen(int sock, int backlog)
35 int r;
37 r = __listen(sock, backlog);
38 if (r != -1 || (errno != ENOTSOCK && errno != ENOSYS))
39 return r;
41 r= ioctl(sock, NWIOTCPLISTENQ, &backlog);
42 if (r != -1 || errno != ENOTTY)
43 return r;
45 r= ioctl(sock, NWIOSUDSBLOG, &backlog);
46 if (r != -1 || errno != ENOTTY)
47 return r;
49 errno = ENOTSOCK;
50 return -1;