socketpair

Top  Previous  Next

The socketpair function creates an unbound pair of connected sockets in a specified domain, of a specified type, under the protocol optionally specified by the protocol argument. The two sockets shall be identical. The file descriptors used in referencing the created sockets shall be returned in socket_vector[0] and socket_vector[1].

 

Syntax

int socketpair(

int domain,

int type,

int protocol,

int *socket_vector

);

 

Parameters

domain

Specifies the communications domain in which the sockets are to be created.

 

type

Specifies the type of sockets to be created.

 

protocol

Specifies a particular protocol to be used with the sockets. Specifying a protocol of 0 causes socketpair to use an unspecified default protocol appropriate for the requested socket type.

 

socket_vector

Specifies a 2-integer array to hold the file descriptors of the created socket pair.

 

Return value

Upon successful completion, socketpair returns 0; otherwise, -1 is returned and errno set to indicate the error.