Accepts a connection on a socket and creates a new socket. The call returns the new socket descriptor. The accept() call is used by the server process to wait for and accept a connection request from the client process.
Syntax
newsocket = accept(socket, addr, addrlen)
int | newsocket, socket, *addrlen; |
struct sockaddr_in | *addr; |
Parameters
newsocket | New socket descriptor created by accept(). If the call is |
| successful, the value returned is an integer equal to or greater |
| than 0. If the call fails, it returns |
socket | Original socket descriptor, created by a previous socket() |
| call. |
addr | Pointer to address structure. The address structure should be |
| of sockaddr_in type. Refer to •Preparing Socket Addresses" |
| in the BSD IPC Reference Manual for NSARPA/1000 and |
| ARPA/1000 for details. |
| On return, this structure contains the socket address of the |
| client process that is connected to the server's new socket. |
addrlen | Pointer to an integer variable that contains the length, in bytes, |
| of the address structure specified by addr (for example, length |
| of structure sockaddr_in, which is 16 bytes). |
| On return, addrlen contains the length, in bytes, of the actual |
| client socket address returned in addr. |
42 Berkeley Software Distribution Interprocess Communication