2 % (c) The GRASP/AQUA Project, Glasgow University, 1995
4 \subsection[createSocket.lc]{Create a socket file descriptor}
11 #ifdef HAVE_SYS_TYPES_H
12 #include <sys/types.h>
15 #ifdef HAVE_SYS_SOCKET_H
16 #include <sys/socket.h>
20 createSocket(I_ family, I_ type, I_ protocol)
24 if ((fd = socket((int)family, (int)type, (int)protocol)) < 0) {
32 ghc_errtype = ERR_PERMISSIONDENIED;
33 ghc_errstr = "cannot create socket";
36 ghc_errtype = ERR_RESOURCEEXHAUSTED;
37 ghc_errstr = "Too many open files";
40 ghc_errtype = ERR_RESOURCEEXHAUSTED;
41 ghc_errstr = "System file table overflow";
43 case GHC_EPROTONOSUPPORT:
44 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
45 ghc_errstr = "Protocol type not supported";
48 ghc_errtype = ERR_INAPPROPRIATETYPE;
49 ghc_errstr = "Protocol wrong type for socket";