diff options
author | simonm <unknown> | 1998-12-02 13:32:30 +0000 |
---|---|---|
committer | simonm <unknown> | 1998-12-02 13:32:30 +0000 |
commit | 438596897ebbe25a07e1c82085cfbc5bdb00f09e (patch) | |
tree | da7a441396aed2e13f6e0cc55282bf041b0cf72c /ghc/lib/misc/cbits/connectSocket.c | |
parent | 967cc47f37cb93a5e2b6df7822c9a646f0428247 (diff) | |
download | haskell-438596897ebbe25a07e1c82085cfbc5bdb00f09e.tar.gz |
[project @ 1998-12-02 13:17:09 by simonm]
Move 4.01 onto the main trunk.
Diffstat (limited to 'ghc/lib/misc/cbits/connectSocket.c')
-rw-r--r-- | ghc/lib/misc/cbits/connectSocket.c | 97 |
1 files changed, 90 insertions, 7 deletions
diff --git a/ghc/lib/misc/cbits/connectSocket.c b/ghc/lib/misc/cbits/connectSocket.c index 28a39d1448..4874cb3bf8 100644 --- a/ghc/lib/misc/cbits/connectSocket.c +++ b/ghc/lib/misc/cbits/connectSocket.c @@ -8,22 +8,105 @@ #endif #define NON_POSIX_SOURCE -#include "rtsdefs.h" +#include "Rts.h" #include "ghcSockets.h" +#include "stgio.h" StgInt -connectSocket(sockfd, servaddr, addrlen, isUnixDomain) -StgInt sockfd; -StgAddr servaddr; -StgInt addrlen; -StgInt isUnixDomain; +connectSocket(I_ sockfd, A_ servaddr, I_ addrlen, I_ isUnixDomain) { int rc; while ((rc = connect((int)sockfd, (struct sockaddr *)servaddr, (int)addrlen)) < 0) { if (errno != EINTR) { cvtErrno(); - stdErrno(); + switch (ghc_errno) { + default: + stdErrno(); + break; + case GHC_EACCES: + ghc_errtype = ERR_PERMISSIONDENIED; + if (isUnixDomain != 0) + ghc_errstr = "For a component of path prefix of path name"; + else + ghc_errstr = "Requested address protected, cannot bind socket"; + break; + case GHC_EISCONN: + case GHC_EADDRINUSE: + ghc_errtype = ERR_RESOURCEBUSY; + ghc_errstr = "Address already in use"; + break; + case GHC_EADDRNOTAVAIL: + ghc_errtype = ERR_PERMISSIONDENIED; + ghc_errstr = "Address not available from local machine"; + break; + case GHC_EAFNOSUPPORT: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Address cannot be used with socket"; + break; + case GHC_EINPROGRESS: + case GHC_EALREADY: + ghc_errtype = ERR_RESOURCEBUSY; + ghc_errstr = "Non-blocking socket, previous connection attempt not completed"; + break; + case GHC_EBADF: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Not a valid socket file descriptor"; + break; + case GHC_ECONNREFUSED: + ghc_errtype = ERR_PERMISSIONDENIED; + ghc_errstr = "Connection rejected"; + break; + case GHC_EFAULT: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Address not in valid part of process address space"; + break; + case GHC_EINVAL: + ghc_errtype = ERR_SYSTEMERROR; + ghc_errstr = "Specified size of structure not equal valid address for family"; + break; + break; + case GHC_ENETUNREACH: + ghc_errtype = ERR_PERMISSIONDENIED; + ghc_errstr = "Network not reachable from host"; + break; + case GHC_ENOTSOCK: + ghc_errtype = ERR_INAPPROPRIATETYPE; + ghc_errstr = "Descriptor for file, not a socket"; + break; + case GHC_ETIMEDOUT: + ghc_errtype = ERR_TIMEEXPIRED; + ghc_errstr = "Connection attempt timed out"; + break; + case GHC_EIO: + ghc_errtype = ERR_SYSTEMERROR; + ghc_errstr = "Could not make directory entry or alloc inode"; + break; + case GHC_EISDIR: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "A null path name was given"; + break; + case GHC_ELOOP: + ghc_errtype = ERR_SYSTEMERROR; + ghc_errstr = "Too many symbolic links encountered"; + break; + case GHC_ENAMETOOLONG: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Max length of path name exceeded"; + break; + case GHC_ENOENT: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Component in path prefix does not exist"; + break; + case GHC_ENOTDIR: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Component in path prefix is not a directory"; + break; + case GHC_EPROTOTYPE: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "File referred to is a socket of differing type"; + break; + } return -1; } } |