← BYTES
Unix IPC·Starter·Ref: 15.1.16

What does socketpair() provide, and how does it relate to a plain pipe?

Have a question about this video? Mention reference 15.1.16 when you contact us.

a.It creates a pair of already-connected, unnamed sockets (typically Unix domain) that two related processes (e.g. a parent and a forked child) can use to communicate bidirectionally -- unlike a plain pipe, which is unidirectional (one fd for reading, one for writing)
b.It creates two completely unrelated, independent sockets with no connection between them
c.It is only usable for communication between different machines over a network
d.It permanently blocks both ends from ever being closed
pipe() gives you two file descriptors that only flow one direction (write into one end, read from the other); socketpair() instead gives you two socket file descriptors that are both full duplex -- either side can read AND write on its own descriptor -- while still being limited, like an anonymous pipe, to processes that share the pair via fork() rather than being independently discoverable by name.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES15116#UnixIPC