accept_and_recv()

The accept_and_recv( ) API accepts a connection on a socket, receives the first message from the connected client, and returns the local and peer addresses.

Syntax

#include <types.h>
#include <sys\socket.h>
#include <netinet\in.h>
#include <sys\time.h>
int accpet_and_recv(s,&sock_accex,&cli_addr,&cli_len,&local,&locallen,outbuff,alloc)
int s;
long sock_accex;
struct sockaddr_in cli_addr;
long cli_len;
struct sockaddr_in local;
long locallen;
char * outbuff;
int alloc;

Parameters

s

sock_accex cli_addr cli_len local_addr locallen outbuff alloc

Description

The accept_and_recv( ) call combines the socket functions accept( ) and recv( ) into a single API transition. The accept_and_recv( ) function accepts a new connection, receives the first block of data from the client and returns the local and remote addresses to the application. The thread sleeping on accept_and_recv( ) wakes-up only after it gets the first data block from the client.

Return Values

The total number of bytes received in the receive buffer associated with the accept_and_recv() is returned upon successful completion and a value of -1 is returned in case of an error.

Error Code

EBADF ECONNABORTED ECONNRESET EFAULT EISCONN ENOTSOCK EOPNOTSUPP ENOREUSE EINTR EINTRNODATA EINVAL EMFILE ENFILE EIO ENOBUFS ENOMEM EPROTO ENOSR

Related Calls


[Back: accept()]
[Next: addsockettolist()]