socketpair

sanjayss via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 30 18:37:07 PST 2015


On Thursday, 31 December 2015 at 02:31:09 UTC, sanjayss wrote:
> On Thursday, 31 December 2015 at 02:26:23 UTC, Rikki Cattermole 
> wrote:
>> On 31/12/15 3:22 PM, sanjayss wrote:
>>> [...]
>>
>> 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
>
> Sure -- I understand the concurrency primitives, but what I was 
> trying to achieve was to have a single foreground loop that 
> could select on a network socket while also watching for a 
> keypress (and in C socketpair is one way you would achieve this 
> using one thread to listen for keypresses -- see 
> http://stackoverflow.com/questions/11461106/socketpair-in-c-unix). How do you suggest I achieve this in D?

OK; one way I realized was to put the network socket select in 
one thread and the watching for keypress in another thread and 
then use the concurrency primitives to message pass events to the 
main thread -- may be a little expensive, but it probably will 
achieve the effect I desire.


More information about the Digitalmars-d-learn mailing list