eaccept Subroutine

Purpose

Accepts a connection on a socket to create a new socket. The eaccept subroutine is similar to the accept subroutine with the addition of the sec_labels_t structure. The sec_labels_t structure reads the Sensitivity Level (SL) that is received on the incoming connection for Trusted AIX® enabled systems.

Library

Standard C Library (libc.a)

Syntax

#include <sys/socket.h>
#include <sys/mac.h>
int eaccept ( Socket,  Address,  AddressLength, Label)
int Socket;
struct sockaddr *Address;
socklen_t *AddressLength;
sec_labels_t *Label;

Description

The eaccept subroutine extracts the first connection in the queue of pending connections, creates a new socket with the same properties as the specified socket, and allocates a new file descriptor for that socket.

If there are no connection requests in the listen queue, the eaccept subroutine performs the following actions:
  • Blocks a calling socket of the blocking type until a connection is present.
  • Returns an EWOULDBLOCK error code for sockets marked nonblocking.

The accepted socket cannot accept more connections, but the original socket remains open and can accept more connections.

The eaccept subroutine is used with only the SOCK_STREAM socket type. If a valid Label parameter is specified, the SL from the incoming connection is returned to the application.

Parameters

Item Description
Socket Specifies a socket created with the socket subroutine that is bound to an address with the bind or ebind subroutine and has issued a successful call to the listen subroutine.
Address Specifies a result parameter that contains the address of the connecting entity as known to the communications layer. The exact format of the Address parameter is determined by the domain in which the communication occurs.
AddressLength Specifies a parameter that initially contains the amount of space pointed to by the Address parameter. Upon return, the parameter contains the actual length (in bytes) of the address returned. The eaccept subroutine is used with SOCK_STREAM socket types.
Label Specifies a result parameter that contains the SL received on the incoming connection.

Return Values

Item Description
Successful a non-negative socket descriptor of the accepted socket
Unsuccessful -1

Error Codes

The eaccept subroutine is unsuccessful if one or more of the following is true:

Item Description
EBADF The Socket parameter is not valid.
EINTR The eaccept function was interrupted by a signal that was caught before a valid connection arrived.
EINVAL The socket referenced by s is not currently a listen socket or has been shutdown with shutdown. A listen must be done before an eaccept is allowed.
EMFILE The number of open file descriptors per process exceeds the system limit (OPEN_MAX).
ENFILE The number of open files exceeds the allowed maximum value.
ENOTSOCK The Socket parameter refers to a file, not a socket.
EOPNOTSUPP The referenced socket is not of type SOCK_STREAM.
EFAULT The Address parameter is not in a writable part of the user address space.
EWOULDBLOCK The socket is marked as nonblocking, and no connections are present to be accepted.
ENETDOWN The network that the socket is associated with is down.
ENOTCONN The socket is not in the connected state.
ECONNABORTED The client aborted the connection.
EPERM The MLS MAC check failed.