socketpair(2) system call
This function should probably be a system call. For Unix sockets, the user-space approach enables a race condition where another thread can theoretically connect to the socket. A potential issue with Unix sockets is what name they should be bound to, if any. I think Linux might put them in an abstract namespace. I suppose the same is true of TCP sockets.