Chapter Contents

Previous

Next
socketpair

socketpair



Creates a Connected Socket Pair

Portability: UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUES
CAUTION
PORTABILITY


SYNOPSIS

#include <sys/types.h>
#include <sys/socket.h>

int socketpair(int domain, int type, int protocol, int fd[2]);


DESCRIPTION

socketpair creates a connected pair of unnamed sockets. The arguments are:

domain
specifies the addressing family that will be used to interpret addresses. AF_UNIX must be specified.

type
specifies the communication service type: either SOCK_STREAM or SOCK_DGRAM may be specified.

protocol
specifies the protocol to be used with the socket pair. This number corresponds to the p_proto field of the protoent structure. If a 0 is specified, the system will select the protocol. Refer to The BSD UNIX Socket Library for information about the protoent structure.

fd
is an array used to hold the file descriptors for the sockets.


RETURN VALUES

If socketpair is successful, it returns 0 ; otherwise, it returns a -1 and sets errno to indicate the type of error.


CAUTION

socketpair is only vaild when integrated sockets are in use.


PORTABILITY

socketpair is portable to other environments, including most UNIX systems that implement BSD sockets.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.