VMS Help
TCPIP Services, Programming Interfaces, Sockets API, accept()
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
Accepts a connection on a passive socket.
The $QIO equivalent is the IO$_ACCESS function with the IO$M_
ACCEPT function modifier.
Format
#include <types.h>
#include <socket.h>
int accept ( int s, struct sockaddr *addr, int *addrlen );
s
A socket descriptor returned by socket(), subsequently bound to
an address with bind(), which is listening for connections after
a listen().
addr
A result parameter filled in with the address of the connecting
entity, as known to the Communications layer. The exact format of
the structure to which the address parameter points is determined
by the domain in which the communication is occurring. This
version of Compaq C supports only the internet domain (AF_INET).
addrlen
A value/result argument. It should initially contain the size of
the structure pointed to by addr. On return it will contain the
actual length, in bytes, of the sockaddr structure that has been
filled in by the Communications layer.
This function completes the first connection on the queue
of pending connections, creates a new socket with the same
properties as s, and allocates and returns a new descriptor
for the socket. If no pending connections are present on the
queue and the socket is not marked as nonblocking, accept()
blocks the caller until a connection request is present. If the
socket is marked nonblocking by using a setsockopt() call and no
pending connections are present on the queue, accept() returns
an error. You cannot use the accepted socket to accept subsequent
connections. The original socket s remains open (listening) for
other connection requests. This call is used with connection-
based socket types (SOCK_STREAM).
Related Functions
See also bind(), connect(), listen(), select(), and socket().
x A nonnegative integer that is a descriptor for
the accepted socket.
-1 Error; errno is set to indicate the error.
EBADF The socket descriptor is invalid.
ECONNABORTED A connection has been aborted.
EFAULT The addr argument is not in a writable part of
the user address space.
EINTR The accept() function was interrupted by a
signal before a valid connection arrived.
EINVAL The socket is not accepting connections.
EMFILE There are too many open file descriptors.
ENFILE The maximum number of file descriptors in the
system is already open.
ENETDOWN TCP/IP Services was not started.
ENOBUFS The system has insufficient resources to
complete the call.
ENOMEM The system was unable to allocate kernel
memory.
ENOTSOCK The socket descriptor is invalid.
EOPNOTSUPP The reference socket is not of type SOCK_
STREAM.
EPROTO A protocol error occurred.
EWOULDBLOCK The socket is marked nonblocking, and no
connections are present to be accepted.
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.