Go to the previous, next section.

socket

SYNOPSIS

int socket(int domain, int type, int protocol);

PARAMETERS

domain: [in] the protocol family of the socket.

type: [in] its type.

protocol: [in] the protocol used for communications.

DESCRIPTION

Creates a communication endpoint. The domain parameter can take the following values:

AF_UNIX
Unix internal protocols.

AF_INET
ARPA protocols (TCP/IP and so on).

AF_ISO
ISO protocols.

AF_NS
Xerox Network System protocols.

AF_IMPLINK
IMP link layer.

As of version 1.0 of Linux: AF_ISO, AF_IMPLINK and AF_NS are not supported.

The type parameter may take the following values:

SOCK_STREAM
full-duplex, reliable, sequenced, connection-oriented stream. Out-of-band data may be supported.

SOCK_DGRAM
connection-less, unreliable link for datagram transmission.

SOCK_RAW
only a task with superuser privileges may use this options (see kernel).

SOCK_SEQPACKET
full-duplex, reliable, sequenced, connection-oriented link for datagram of a specified size. Usable only with the AF_NS domain.

SOCK_RDM
not implemented yet.

The SOCK_STREAM type provide reliable transmission. Even when the connection is not transmitting usefull information, a packet is send at a regular interval to ensure that the connection is still intact.

RETURN VALUE

On success, a new file descriptor for the socket is returned. On error, -1 is returned and errno is set to one of the following values:

Go to the previous, next section.