INtime SDK Help
accept (legacy networking)
INtime Help

Accepts a connection on a socket.

This call gets the first connection request from the queue of pending connections and creates a new socket with the same properties as s. The call accepts the connection on the new socket and returns a file descriptor for that socket. You cannot accept more connections on the new socket; the original socket s remains open.

If no pending connections are present on the queue and the socket is not marked as non-blocking, this call blocks the caller until a connection request arrives. If the socket is marked non-blocking and no pending connections are present on the queue, this call returns an error.

int accept(
    int s,
    struct sockaddr* addr,
    int* addrlen
);

Parameters

s
A socket of type SOCK_STREAM, created with socket, bound to an address with bind, and currently listening for connections with listen.
addr
Points to a structure that this call fills in with the address of the connected peer. The format of the returned address is determined by the domain in which the communication occurs.
addrlen
Initialize to the number of bytes in the buffer referenced by addr. On return, addrlen contains the actual length in bytes of the returned address.

Return Values

A non-negative integer that is a descriptor for the accepted socket, created by this call.
Success.
-1, and the function sets errno to one of these values:
EBADF Invalid file descriptor or file not opened for writing.
ENOSPC No space left on device.
Failure.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/sys/socket.h sys/types.h
sys/socket.h
netiff3m.lib

 

See Also