socketpair¶
socketpair() creates a pair of connected sockets.
It is useful for local parent/child communication and for building small IPC channels without binding a pathname socket.
Prototype¶
Typical Usage¶
Parameters¶
| Parameter | Description |
|---|---|
domain |
Usually AF_UNIX |
type |
Usually SOCK_STREAM or SOCK_DGRAM |
protocol |
Usually 0 |
sv |
Output array containing two connected socket descriptors |
Return Value¶
0on success-1on error, witherrnoset
Common Pitfalls¶
Warning
Close the unused socket end after fork(). Otherwise EOF detection may not work as expected.