-
Notifications
You must be signed in to change notification settings - Fork 1
zaccept()
Pradeep S B edited this page Aug 20, 2014
·
3 revisions
#####int zaccept ( int sockfd, struct sockaddr * cliaddr, socklen_t * addrlen )
zaccept() call intercepts the accept system call.
zaccept() used with connection-based socket types (SOCK_STREAM, SOCK_SEQPACKET), It extracts the first connection request on the queue of pending connections for the listening socket, sockfd, creates a new connected socket, and returns a new file descriptor referring to that socket.
######Example usage:
#include "zerosocket.h"
⋮
int newclient_sock;
int server_sock;
struct sockaddr client_addr;
int addrlen;
//zsocket, zbind, and zlisten have been called
⋮
addrlen = sizeof(client_addr);
newclient_sock = zaccept((server_sock,&client_addr, &addrlen));
######Parameters:
| Parameter | Description |
|---|---|
| sockd | sockfd is a socket that has been created with zsocket, bound to a local address with zbind, and is listening for connections after a zlisten |
| cliaddr | cliaddr is a pointer to a sockaddr structure. This structure is filled in with the address of the peer socket, as known to the communications layer |
| addrlen | addrlen argument is a value-result argument: the caller must initialize it to contain the size (in bytes) of the structure pointed to by addr; on return it will contain the actual size of the peer address |
######Returns
On success, these system calls return a nonnegative integer that is a descriptor for the accepted socket. On error, -1 is returned, and errno is set appropriately.
######See Also
accept man accept
| Wiki - Zero Socket client library | Home | |------|---------------------------|