On 31/12/15 3:22 PM, sanjayss wrote:
std.socket supports the socketpair() function, but it seems like this
api is not really usable in any of the concurrency primitives supported
by D. So what is the purpose of the socketpair() support?

Basically I am trying to create two threads and am trying to use
socketpair() to create two sockets and use them to communicate between
the threads, but none of the socket API's allow use of shared
socket-pair (probably correctly so). So how else can one implement a
foreground event loop that supports both key-presses and network socket
events -- I was hoping to do the keyboard event in one thread and use
the socketpair to communicate to the actual foreground event loop via
the socketpair sockets.

Any help on how one would code this in D is welcome.

Wrong tool for the job.
You want message passing not sockets to communicate between threads in this case.

You're wanting the functions receive and send relating to:
http://dlang.org/phobos/std_concurrency.html

Reply via email to