Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

socketpair(2) [redhat man page]

SOCKETPAIR(2)						     Linux Programmer's Manual						     SOCKETPAIR(2)

NAME
socketpair - create a pair of connected sockets SYNOPSIS
#include <sys/types.h> #include <sys/socket.h> int socketpair(int d, int type, int protocol, int sv[2]); DESCRIPTION
The socketpair call creates an unnamed pair of connected sockets in the specified domain d, of the specified type, and using the optionally specified protocol. The descriptors used in referencing the new sockets are returned in sv[0] and sv[1]. The two sockets are indistin- guishable. RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS
EMFILE Too many descriptors are in use by this process. EAFNOSUPPORT The specified address family is not supported on this machine. EPROTONOSUPPORT The specified protocol is not supported on this machine. EOPNOTSUPP The specified protocol does not support creation of socket pairs. EFAULT The address sv does not specify a valid part of the process address space. CONFORMING TO
4.4BSD (the socketpair function call appeared in 4.2BSD). Generally portable to/from non-BSD systems supporting clones of the BSD socket layer (including System V variants). NOTES
On Linux, the only supported domain for this call is AF_UNIX (or synonymously, AF_LOCAL). (Most implementations have the same restric- tion.) SEE ALSO
read(2), write(2), pipe(2), socket(2), unix(7) BSD Man Page 1993-07-24 SOCKETPAIR(2)

Check Out this Related Man Page

SOCKETPAIR(2)						      BSD System Calls Manual						     SOCKETPAIR(2)

NAME
socketpair -- create a pair of connected sockets LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/socket.h> int socketpair(int d, int type, int protocol, int *sv); DESCRIPTION
The socketpair() call creates an unnamed pair of connected sockets in the specified domain d, of the specified type, and using the optionally specified protocol. The descriptors used in referencing the new sockets are returned in sv[0] and sv[1]. The two sockets are indistinguish- able. The type and protocol argument values are described in socket(2). RETURN VALUES
A 0 is returned if the call succeeds, -1 if it fails. ERRORS
The call succeeds unless: [EAFNOSUPPORT] The specified address family is not supported on this machine. [EFAULT] The address sv does not specify a valid part of the process address space. [EMFILE] Too many descriptors are in use by this process. [ENFILE] The system file table is full. [EOPNOTSUPP] The specified protocol does not support creation of socket pairs. [EPROTONOSUPPORT] The specified protocol is not supported on this machine. SEE ALSO
pipe(2), read(2), socket(2), write(2) HISTORY
The socketpair() function call appeared in 4.2BSD. BUGS
This call is currently implemented only for the PF_LOCAL domain. BSD
June 24, 2011 BSD
Man Page

6 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

IP address

Hi All, I logged into to a unix machine, from $ prompt what should I type to get IP address of that machine? Thanks inadvance, Krishna (10 Replies)
Discussion started by: krishna
10 Replies

2. Programming

socketpair

what is the difference to use socketpair and socket while socket programming other than socket create a single socket,socketpair creates a pair of sockets (0 Replies)
Discussion started by: MKSRaja
0 Replies

3. HP-UX

fd passing between Independent processes using unix domain sockets

Hi, I am having some error handling issues with and fd passed between Independent processes using unix domain sockets (On HPUX). Here is the scnerio ================= Step 1: TPC/Client (connect()) ---Connects to ------TCP/Server(Gateway) (server gets fd) Step 2: ... (2 Replies)
Discussion started by: Debasisb2002
2 Replies

4. UNIX for Advanced & Expert Users

IP address of machine

Hi i want to know the Ip address of the machine from where i logged into the unix server and made some changes to a file. Can I know the last changes made to a unix file ? (3 Replies)
Discussion started by: harneet2004us
3 Replies

5. Programming

Linux BSD sockets blocking issue

I am using BSD TCP sockets under Debian Linux 2.6 and no matter what I do, the socket blocks on recv. I have set O_NONBLOCK and O_NDELAY using fcntl to no effect. Any ideas ? (3 Replies)
Discussion started by: johnmb
3 Replies

6. Programming

Two player game, forking & sockets

Hi. I am just making first steps in Linux POSIX programming. I have read some tutorials on processes, signals and sockets (thanks Beej!), so some basic knowledge I have already got. I want to write some very basic game server. My idea is to have main process, which is waiting for new players. If... (7 Replies)
Discussion started by: Shang
7 Replies