[project @ 1996-06-27 16:13:29 by partain]
[ghc-hetmet.git] / ghc / runtime / io / shutdownSocket.lc
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1996
3 %
4 \subsection[shutdownSocket.lc]{Shut down part of full duplex connection}
5
6 \begin{code}
7
8 #include "rtsdefs.h"
9 #include "stgio.h"
10
11 StgInt
12 shutdownSocket(int sockfd, int how)
13 {
14     StgInt rc;
15     
16     while ((rc = shutdown(sockfd, how)) < 0) {
17       if (errno != EINTR) {
18           cvtErrno();
19           switch (ghc_errno) {
20           default:
21               stdErrno();
22               break;
23           case GHC_EBADF:
24               ghc_errtype = ERR_INVALIDARGUMENT;
25               ghc_errstr  = "Not a valid write descriptor";
26               break;
27           case GHC_ENOTCONN:
28               ghc_errtype = ERR_INVALIDARGUMENT;
29               ghc_errstr  = "Socket not connected";
30               break;
31           case GHC_ENOTSOCK:
32               ghc_errtype = ERR_INVALIDARGUMENT;
33               ghc_errstr  = "Descriptor is not a socket";
34               break;
35           }
36           return -1;
37       }
38     }
39     return rc;
40 }
41
42 \end{code}