2 % (c) The GRASP/AQUA Project, Glasgow University, 1996
4 \subsection[acceptSocket.lc]{Server wait for client to connect}
11 #ifdef HAVE_SYS_TYPES_H
12 #include <sys/types.h>
15 #ifdef HAVE_SYS_SOCKET_H
16 #include <sys/socket.h>
20 acceptSocket(I_ sockfd, A_ peer, A_ addrlen)
24 while ((fd = accept((int)sockfd, (struct sockaddr *)peer, (int *)addrlen)) < 0) {
32 ghc_errtype = ERR_INVALIDARGUMENT;
33 ghc_errstr = "Not a valid descriptor";
36 ghc_errtype = ERR_INVALIDARGUMENT;
37 ghc_errstr = "Address not in writeable part of user address space";
40 ghc_errtype = ERR_INVALIDARGUMENT;
41 ghc_errstr = "Descriptor not a socket";
44 ghc_errtype = ERR_INVALIDARGUMENT;
45 ghc_errstr = "Socket not of type that supports listen";
48 ghc_errtype = ERR_OTHERERROR;
49 ghc_errstr = "No sockets are present to be accepted";