Socket and spawn()

kdevel kdevel at vogtner.de
Fri May 31 19:48:37 UTC 2024


On Friday, 31 May 2024 at 16:07:23 UTC, Andy Valencia wrote:
> I'm coding a server which takes TCP connections.  I end up in 
> the main thread with .accept() which hands me a Socket.  I'd 
> like to hand this off to a spawn()'ed thread to do the actual 
> work.

Have you taken into consideration that each of the (pre-spawned) 
threads
can call accept()? Your program may also accept in multiple 
processes
on the same socket. [1]

[1] 
https://stackoverflow.com/questions/11488453/can-i-call-accept-for-one-socket-from-several-threads-simultaneously


More information about the Digitalmars-d-learn mailing list