Overview:
-
The socket.socketpair() creates a pair of sockets and connects them together which is returned as a tuple.
-
The communication between the sockets is full-duplex. Both sockets can send and receive simultaneously.
Example:
# Example Python program that creates def msgParentProc(childSocket): def msgChildProc(parentSocket): # Create a socket pair using Unix domain protocol childProcSocket = sockPair[0] retVal = os.fork() if retVal == 0: |
Output:
Parent pid:7901 Child pid:7902 Hi from parent Hi from child |