31e91b8283fd55fbf146587d01fbbf572f44a6e7
[ghc-hetmet.git] / ghc / lib / misc / cbits / createSocket.c
1 #if 0
2 %
3 % (c) The GRASP/AQUA Project, Glasgow University, 1995
4 %
5 \subsection[createSocket.lc]{Create a socket file descriptor}
6
7 \begin{code}
8 #endif
9
10 #define NON_POSIX_SOURCE
11 #include "rtsdefs.h"
12 #include "ghcSockets.h"
13
14 StgInt
15 createSocket(I_ family, I_ type, I_ protocol)
16 {
17     int fd;
18
19     if ((fd = socket((int)family, (int)type, (int)protocol)) < 0) {
20       if (errno != EINTR) {
21           cvtErrno();
22           stdErrno();
23           return -1;
24       }
25     }
26     return fd;
27 }