BSD Sockets Interface Programmer's Guide

Chapter 6 131
Using UNIX Domain Stream Sockets
Writing the Server Process
Accepting a Connection
The server process can accept any connection requests that enter its
queue after it executes listen. accept creates a new socket for the
connection and returns the socket descriptor for the new socket. The new
socket:
Is created with the same properties as the old socket.
Has the same bound pathname as the old socket.
Is connected to the client process' socket.
accept blocks until there is a connection request from a client process in
the queue, unless you are using nonblocking I/O. accept and its
parameters are described in the following table.
Include files: #include <sys/types.h>
#include <sys/un.h>
#include <sys/socket.h>
System call: s = accept(ls,addr,addrlen)
int s;
int ls;
struct sockaddr_un *addr;
int *addrlen;
Parameter Contents INPUT Value
OUTPUT
Value
s socket
descriptor of
local socket
socket descriptor
of server socket
unchanged
addr socket
address
pointer to address
structure where
address will be put
pointer to
socket address of
client socket
that server’s
new socket is
connected to
addrlen length of
address
pointer to the size
of struct
sockaddr_un
pointer to the
actual length of
address
returned in addr