Using socketpair for inter-thread communication