Re: Read from and Write to the same socket from two threads



Thanks. Walter.

The FAQ page means the following:

Anecdotal evidence suggests that one thread calling send() and another thread calling recv() on a single socket is safe on recent Microsoft stacks at least.

Could you confirm the above for me? If it safe to read from one thread and write to the same socket in another thread. I will not want to implement the synchronizations.

Charles Zhang

Walter Wang [MSFT] wrote:
Hi Charles,

While calling send() in one thread and recv() in another thread is safe, order of winsock functions in two threads on one socket handle might cause other issues. It's recommended to provide thread safety yourself. Please see winsock FAQ on this:

Winsock Programmer's FAQ: Intermediate Winsock Issues (http://tangentsoft.net/wskfaq/intermediate.html#threadsafety)


Hope this helps.


Regards,
Walter Wang (wawang@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • Re: Read from and Write to the same socket from two threads
    ... Anecdotal evidence suggests that one thread calling sendand another ... thread calling recv() on a single socket is safe on recent Microsoft ... and write to the same socket in another thread. ...
    (microsoft.public.win32.programmer.networks)
  • [PATCH] bluetooth : rfcomm tty BUG_ON() code fix
    ... /* It's safe to call module_puthere because socket still ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: [OT] how to clean grime off old computer MB?
    ... I don't want to remove e.g. the CPU from its socket. ... You need to remove all socketed devices, and especially the CPU. ... which presumably is safe for the ... believe was safe for aluminum electrolytics; ...
    (Debian-User)
  • Re: Socket Send and Receive Thread Safety
    ... > Socket.Send on the same Socket at the same time? ... > thread safe, but I'm not sure whether this combination is or not. ... socket (so called mutating methods) simultaneously with other methods ... Recv and Send are usually considered non-mutating ...
    (microsoft.public.win32.programmer.networks)
  • Re: [ANNOUNCE] LiSt - Linux Statistics - www.linux-stats.org
    ... Everyone's is going to be Darkstar. ... safe. ... Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)