accept()

It accepts a new connection on the listening socket, that is, the first connection from the queue of pending connections is picked up. Actuallya new socket is created with the same socket type protocol and address family as the specified socket, and a new file descriptor is allocated for that socket. Here is its syntax:

int accept(int socket, struct sockaddr *address, socklen_t *len);

Here, we need to address the following:

  • socket: Represents the file descriptor of the socket waiting for the new connection. This is the socket that is created when the socket function is bound to an address with the bind function, and has invoked the listen function successfully.
  • address: The address of the connecting socket is returned through this parameter. It is a pointer to a sockaddr structure, through which the address of the connecting socket is returned.
  • len: Represents the length of the supplied sockaddr structure. When returned, this parameter contains the length of the address returned in bytes.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset