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"
16 bindSocket(I_ sockfd, A_ myaddr, I_ addrlen, I_ isUnixDomain)
20 while ((rc = bind((int)sockfd, (struct sockaddr *)myaddr, (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";
44 ghc_errtype = ERR_INVALIDARGUMENT;
45 ghc_errstr = "Not a valid socket file descriptor";
48 ghc_errtype = ERR_INVALIDARGUMENT;
49 ghc_errstr = "Address not in valid part of user address space";
52 ghc_errtype = ERR_SYSTEMERROR;
53 ghc_errstr = "Specified size of structure not equal valid address for family";
56 ghc_errtype = ERR_INAPPROPRIATETYPE;
57 ghc_errstr = "Descriptor for file, not a socket";
60 ghc_errtype = ERR_SYSTEMERROR;
61 ghc_errstr = "Could not make directory entry or alloc inode";
64 ghc_errtype = ERR_INVALIDARGUMENT;
65 ghc_errstr = "A null path name was given";
68 ghc_errtype = ERR_SYSTEMERROR;
69 ghc_errstr = "Too many symbolic links encountered";
71 case GHC_ENAMETOOLONG:
72 ghc_errtype = ERR_INVALIDARGUMENT;
73 ghc_errstr = "Max length of path name exceeded";
76 ghc_errtype = ERR_INVALIDARGUMENT;
77 ghc_errstr = "Component in path prefix does not exist";
80 ghc_errtype = ERR_INVALIDARGUMENT;
81 ghc_errstr = "Component in path prefix is not a directory";
84 ghc_errtype = ERR_INVALIDARGUMENT;
85 ghc_errstr = "The inode would reside on read only file system";