Using UNIX Domain Stream Sockets
Writing the Server Process
Function result: socket descriptor of new socket if accept is successful,
–1 if failure occurs.
Example:
struct sockaddr_un peeraddr;
...
addrlen = sizeof(sockaddr_un);
s = accept (ls, &peeraddr, &addrlen);
There is no way for the server process to indicate which requests it can
accept. It must accept all requests or none.
When to Accept a Connection
The server process should accept a connection after executing the listen
call. Refer to the accept(2) man page for more information on accept.
132
Chapter 6