diff options
author | sof <unknown> | 1998-08-14 10:17:45 +0000 |
---|---|---|
committer | sof <unknown> | 1998-08-14 10:17:45 +0000 |
commit | 19a4b25b9ecd4a05e784110e9429e67d5643f2c2 (patch) | |
tree | f1fa1e9c492b1c5d45a03bf03f2ac491fa9b3fc2 /ghc/lib/misc/cbits/socketOpt.c | |
parent | 2a62415d5fb5e094a99e77f9562866b227fa4b33 (diff) | |
download | haskell-19a4b25b9ecd4a05e784110e9429e67d5643f2c2.tar.gz |
[project @ 1998-08-14 10:17:35 by sof]
Added stubs for getsockopt() and setsockopt(),
removed redundant ghc_errno switches, use stdErrno()
instead.
Diffstat (limited to 'ghc/lib/misc/cbits/socketOpt.c')
-rw-r--r-- | ghc/lib/misc/cbits/socketOpt.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ghc/lib/misc/cbits/socketOpt.c b/ghc/lib/misc/cbits/socketOpt.c new file mode 100644 index 0000000000..e8d5d843c1 --- /dev/null +++ b/ghc/lib/misc/cbits/socketOpt.c @@ -0,0 +1,63 @@ +#if 0 +% +% (c) The GRASP/AQUA Project, Glasgow University, 1998 +% +\subsection[socketOpt.lc]{Setting/Getting socket opts} + +\begin{code} +#endif + +#define NON_POSIX_SOURCE +#include "rtsdefs.h" +#include "ghcSockets.h" + +StgInt +getSocketOption__ (fd, opt) +StgInt fd; +StgInt opt; +{ + int level,optval, sz_optval,rc; + + if ( opt == TCP_MAXSEG || opt == TCP_NODELAY ) { + level = IPPROTO_TCP; + } else { + level = SOL_SOCKET; + } + + sz_optval = sizeof(int); + + while ( (rc = getsockopt((int)fd, level, opt, &optval, &sz_optval)) < 0 ) { + if (errno != EINTR) { + cvtErrno(); + stdErrno(); + return -1; + } + } + return optval; +} + +StgInt +setSocketOption__ (fd, opt, val) +StgInt fd; +StgInt opt; +StgInt val; +{ + int level, optval,rc; + + if ( opt == TCP_MAXSEG || opt == TCP_NODELAY ) { + level = IPPROTO_TCP; + } else { + level = SOL_SOCKET; + } + + optval = val; + + while ( (rc = setsockopt((int)fd, level, opt, &optval, sizeof(optval))) < 0 ) { + if (errno != EINTR) { + cvtErrno(); + stdErrno(); + return -1; + } + } + return 0; +} |