- Unison Kernel
- Pthread Cancellation
- Message Queues
- Conditional Variables
- Memory Allocation
- Directory Services
- Unison I/O Library
- Unison STDIO Library
- STDIO Library Calls
- Do-nothing Stubs
- STDIO Library Calls
- Unison LIBC Library
- Unison I/O Servers
- Graphics, Camera, Video, Audio
- Network Protocols
- TCP and UDP Server - tcpd
- DHCP Client Service - dhcp client
- DHCP Server - dhcpd
- Telnet Server - telnetd
- Tiny FTP Server - tftpd
- Point to Point - pppd
- Network Translation - NAT with PAT
- Tiny HTTP Server - thttpd
- Tiny HTTP Server with TLS
- POP3 Server
- Simple Mail Transfer Protocol Services (SMTP)
- Bootp Protocol
- File Transfer Protocol Server (FTP)
- File Transfer Client Services
- RPC / XDR
- DNS Client
- HTTP/HTTPS Client
- REST Client
- AutoIP Service - autoip client
- mDNS server - mdnsd
- SNTP Client
- SNMP Agent - Snmpd server
- SSL/TLS library
- SSH server
- IP security
- Power Control
- Serial I/O
- System Services
- Universal Serial Bus (USB)
- Remedy Tools for Unison
accept – accept a connection on a socket
- int accept(int s , struct sockaddr *addr , socklen_t *addrlen );
The argument s is a socket that has been created with socket() and bound to an address with bind(), and that is listening for connections after a call to listen(). accept() extracts the first connection on the queue of pending connections, creates a new socket with the properties of s, and allocates a new file descriptor, ns , for the socket. If no pending connections are present on the queue and the socket is not marked as non-blocking, accept() blocks the caller until a connection is present. If the socket is marked as non-blocking and no pending connections are present on the queue, accept() returns an error as described below.
The accepted socket, ns , is used to read and write data to and from the socket that connected to ns; it is not used to accept more connections. The original socket (s) remains open for accepting further connections.
The argument addr is a result parameter that is filled in with the address of the connecting entity as it is known to the communications layer. The exact format of the addr parameter is determined by the domain in which the communication occurs.
addrlen is a value-result parameter. Initially, it contains the amount of space pointed to by addr ; on return it contains the length in bytes of the address returned.
accept() is used with connection-based socket types, currently with SOCK_STREAM.
It is NOT possible to select() or pool() a socket for the purpose of an accept() in the system.
accept() returns -1 on error. If it succeeds, it returns a non-negative integer that is a descriptor for the accepted socket.
This function is a member of Unison’s IOLIB family of functions. IOLIB is implemented as a message passing and generalized interface layer. Each Unison I/O server is responsible for its own error reporting.
For an exact list of error codes returned by a particular server, refer to that server’s documentation in the Unison Programmer’s Guide for each specific platform.
Servers may implement these errors codes in response to this function.
accept() will fail if:
- EAGAIN or EWOULDBLOCK
- The socket is marked as non-blocking and no connections are present to be accepted.
- The descriptor is invalid.
- A connection has been aborted.
- There was insufficient user memory available to complete the operation.
- The descriptor does not reference a socket.
- The maximum number of file descriptors in the system are already open.
- The socket is not accepting connections.
- The socket type of the specified socket does not support accepting connections.
- A protocol error has occurred; for example, the protocol stack has not been initialized.