3 % (c) The GRASP/AQUA Project, Glasgow University, 1995
5 \subsection[connectSocket.lc]{Assign name to client socket}
10 #define NON_POSIX_SOURCE
12 #include "ghcSockets.h"
16 connectSocket(I_ sockfd, A_ servaddr, I_ addrlen, I_ isUnixDomain)
20 while ((rc = connect((int)sockfd, (struct sockaddr *)servaddr, (int)addrlen)) < 0) {
28 ghc_errtype = ERR_PERMISSIONDENIED;
29 if (isUnixDomain != 0)
30 ghc_errstr = "For a component of path prefix of path name";
32 ghc_errstr = "Requested address protected, cannot bind socket";
36 ghc_errtype = ERR_RESOURCEBUSY;
37 ghc_errstr = "Address already in use";
39 case GHC_EADDRNOTAVAIL:
40 ghc_errtype = ERR_PERMISSIONDENIED;
41 ghc_errstr = "Address not available from local machine";
43 case GHC_EAFNOSUPPORT:
44 ghc_errtype = ERR_INVALIDARGUMENT;
45 ghc_errstr = "Address cannot be used with socket";
49 ghc_errtype = ERR_RESOURCEBUSY;
50 ghc_errstr = "Non-blocking socket, previous connection attempt not completed";
53 ghc_errtype = ERR_INVALIDARGUMENT;
54 ghc_errstr = "Not a valid socket file descriptor";
56 case GHC_ECONNREFUSED:
57 ghc_errtype = ERR_PERMISSIONDENIED;
58 ghc_errstr = "Connection rejected";
61 ghc_errtype = ERR_INVALIDARGUMENT;
62 ghc_errstr = "Address not in valid part of process address space";
65 ghc_errtype = ERR_SYSTEMERROR;
66 ghc_errstr = "Specified size of structure not equal valid address for family";
70 ghc_errtype = ERR_PERMISSIONDENIED;
71 ghc_errstr = "Network not reachable from host";
74 ghc_errtype = ERR_INAPPROPRIATETYPE;
75 ghc_errstr = "Descriptor for file, not a socket";
78 ghc_errtype = ERR_TIMEEXPIRED;
79 ghc_errstr = "Connection attempt timed out";
82 ghc_errtype = ERR_SYSTEMERROR;
83 ghc_errstr = "Could not make directory entry or alloc inode";
86 ghc_errtype = ERR_INVALIDARGUMENT;
87 ghc_errstr = "A null path name was given";
90 ghc_errtype = ERR_SYSTEMERROR;
91 ghc_errstr = "Too many symbolic links encountered";
93 case GHC_ENAMETOOLONG:
94 ghc_errtype = ERR_INVALIDARGUMENT;
95 ghc_errstr = "Max length of path name exceeded";
98 ghc_errtype = ERR_INVALIDARGUMENT;
99 ghc_errstr = "Component in path prefix does not exist";
102 ghc_errtype = ERR_INVALIDARGUMENT;
103 ghc_errstr = "Component in path prefix is not a directory";
106 ghc_errtype = ERR_INVALIDARGUMENT;
107 ghc_errstr = "File referred to is a socket of differing type";