source: trunk/minix/lib/ip/shutdown.c@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 897 bytes
Line 
1#include <errno.h>
2#include <stdio.h>
3#include <sys/ioctl.h>
4#include <sys/socket.h>
5
6#include <net/gen/in.h>
7#include <net/gen/tcp.h>
8#include <net/gen/tcp_io.h>
9
10#define DEBUG 1
11
12static int _tcp_shutdown(int socket, int how);
13
14int shutdown(int socket, int how)
15{
16 int r;
17 nwio_tcpconf_t tcpconf;
18
19 r= ioctl(socket, NWIOGTCPCONF, &tcpconf);
20 if (r != -1 || errno != ENOTTY)
21 {
22 if (r == -1)
23 {
24 /* Bad file descriptor */
25 return -1;
26 }
27 return _tcp_shutdown(socket, how);
28 }
29#if DEBUG
30 fprintf(stderr, "shutdown: not implemented for fd %d\n", socket);
31#endif
32 errno= ENOSYS;
33 return -1;
34}
35
36static int _tcp_shutdown(int socket, int how)
37{
38 int r;
39
40 if (how == SHUT_WR || how == SHUT_RDWR)
41 {
42 r= ioctl(socket, NWIOTCPSHUTDOWN, NULL);
43 if (r == -1)
44 return -1;
45 if (how == SHUT_WR)
46 return 0;
47 }
48
49 /* We can't shutdown the read side of the socket. */
50 errno= ENOSYS;
51 return -1;
52}
53
54
Note: See TracBrowser for help on using the repository browser.