[Chapter 3] 3.2.152 socketpair
Author: Larry Wall, Tom Christiansen & Randal L. Schwartz
Date: 1999-07-02T01:54:22Z

#

| Chapter 3 Functions |

### 3.2.152 socketpair

    socketpair SOCKET1, SOCKET2, DOMAIN, TYPE, PROTOCOL

This function creates an unnamed pair of sockets in the specified domain, of the specified type. `DOMAIN`, `TYPE`, and `PROTOCOL` are specified the same as for socketpair(2). If socketpair(2) is unimplemented, invoking this function yields a fatal error. The function returns true if successful.

This function is typically used just before a fork. One of the resulting processes should close `SOCKET1`, and the other should close `SOCKET2`. You can use these sockets bidirectionally, unlike the filehandles created by the pipe function.

3.2.151 socket |  | 3.2.153 sort