forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlisten.c
More file actions
51 lines (41 loc) · 920 Bytes
/
Copy pathlisten.c
File metadata and controls
51 lines (41 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/gen/in.h>
#include <net/gen/tcp.h>
#include <net/gen/tcp_io.h>
#include <net/gen/udp.h>
#include <net/gen/udp_io.h>
/*
* Put a socket in listening mode.
*/
static int
__listen(int fd, int backlog)
{
message m;
memset(&m, 0, sizeof(m));
m.m_lc_vfs_listen.fd = fd;
m.m_lc_vfs_listen.backlog = backlog;
return _syscall(VFS_PROC_NR, VFS_LISTEN, &m);
}
int listen(int sock, int backlog)
{
int r;
r = __listen(sock, backlog);
if (r != -1 || (errno != ENOTSOCK && errno != ENOSYS))
return r;
r= ioctl(sock, NWIOTCPLISTENQ, &backlog);
if (r != -1 || errno != ENOTTY)
return r;
r= ioctl(sock, NWIOSUDSBLOG, &backlog);
if (r != -1 || errno != ENOTTY)
return r;
errno = ENOTSOCK;
return -1;
}