3 % (c) The GRASP/AQUA Project, Glasgow University, 1995
5 \subsection[bindSocket.lc]{Assign name to unnamed socket}
10 #define NON_POSIX_SOURCE
12 #include "ghcSockets.h"
15 bindSocket(I_ sockfd, A_ myaddr, I_ addrlen, I_ isUnixDomain)
19 while ((rc = bind((int)sockfd, (struct sockaddr *)myaddr, (int)addrlen)) < 0) {
27 ghc_errtype = ERR_PERMISSIONDENIED;
28 if (isUnixDomain != 0)
29 ghc_errstr = "For a component of path prefix of path name";
31 ghc_errstr = "Requested address protected, cannot bind socket";
35 ghc_errtype = ERR_RESOURCEBUSY;
36 ghc_errstr = "Address already in use";
38 case GHC_EADDRNOTAVAIL:
39 ghc_errtype = ERR_PERMISSIONDENIED;
40 ghc_errstr = "Address not available from local machine";
43 ghc_errtype = ERR_INVALIDARGUMENT;
44 ghc_errstr = "Not a valid socket file descriptor";
47 ghc_errtype = ERR_INVALIDARGUMENT;
48 ghc_errstr = "Address not in valid part of user address space";
51 ghc_errtype = ERR_SYSTEMERROR;
52 ghc_errstr = "Specified size of structure not equal valid address for family";
55 ghc_errtype = ERR_INAPPROPRIATETYPE;
56 ghc_errstr = "Descriptor for file, not a socket";
59 ghc_errtype = ERR_SYSTEMERROR;
60 ghc_errstr = "Could not make directory entry or alloc inode";
63 ghc_errtype = ERR_INVALIDARGUMENT;
64 ghc_errstr = "A null path name was given";
67 ghc_errtype = ERR_SYSTEMERROR;
68 ghc_errstr = "Too many symbolic links encountered";
70 case GHC_ENAMETOOLONG:
71 ghc_errtype = ERR_INVALIDARGUMENT;
72 ghc_errstr = "Max length of path name exceeded";
75 ghc_errtype = ERR_INVALIDARGUMENT;
76 ghc_errstr = "Component in path prefix does not exist";
79 ghc_errtype = ERR_INVALIDARGUMENT;
80 ghc_errstr = "Component in path prefix is not a directory";
83 ghc_errtype = ERR_INVALIDARGUMENT;
84 ghc_errstr = "The inode would reside on read only file system";