X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fruntime%2Fio%2FlistenSocket.lc;fp=ghc%2Fruntime%2Fio%2FlistenSocket.lc;h=d9260cfc39a3c06aef9e6dd707fa9fa03c216c85;hb=769ce8e72ae626356ce57162b7ff448c0ef7e700;hp=0000000000000000000000000000000000000000;hpb=a7e6cdbfc4f27c2e0ab9c12ebe6431c246c74c6d;p=ghc-hetmet.git diff --git a/ghc/runtime/io/listenSocket.lc b/ghc/runtime/io/listenSocket.lc new file mode 100644 index 0000000..d9260cf --- /dev/null +++ b/ghc/runtime/io/listenSocket.lc @@ -0,0 +1,50 @@ +% +% (c) The GRASP/AQUA Project, Glasgow University, 1996 +% +\subsection[listenSocket.lc]{Indicate willingness to receive connections} + +\begin{code} + +#include "rtsdefs.h" +#include "stgio.h" + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +StgInt +listenSocket(int sockfd, int backlog) +{ + int rc; + + while ((rc = listen(sockfd, backlog)) < 0) { + if (errno != EINTR) { + cvtErrno(); + switch (ghc_errno) { + default: + stdErrno(); + break; + case GHC_EBADF: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Not a valid descriptor"; + break; + case GHC_ENOTSOCK: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Descriptor not a socket"; + break; + case GHC_EOPNOTSUPP: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Socket not of type that supports listen"; + break; + } + return -1; + } + } + return 0; +} + +\end{code}