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

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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: Error using P/Invoke with Winsock API using CF.NET
    ... > System.Net.Sockets wraps the Winsock APIs and the Handle exposed is actually ... >>I need to call additional winsock functions that are not available through ... I can create a new socket using the winsock socket ... >> documented issue with calling native winsock P/Invoke functions from ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Error using P/Invoke with Winsock API using CF.NET
    ... System.Net.Sockets wraps the Winsock APIs and the Handle exposed is actually ... P/Invoke definition - under XP you would use ws2_32.dll, ... >I need to call additional winsock functions that are not available through ... I can create a new socket using the winsock socket ...
    (microsoft.public.dotnet.framework.compactframework)
  • Error using P/Invoke with Winsock API using CF.NET
    ... I need to call additional winsock functions that are not available through ... I can create a new socket using the winsock socket ... documented issue with calling native winsock P/Invoke functions from CF.NET ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: help me with my understanding of WSPRecv/From
    ... WinSock has some MS-specific functions to employ the NT ... WinSock has a common provider DLL called MSAFD.DLL. ... AFD.SYS is a kernel module which implements the sockets semantics on top of ... This will give you lots of socket stuff, ...
    (microsoft.public.development.device.drivers)
  • Re: help me with my understanding of WSPRecv/From
    ... WinSock has some MS-specific functions to employ the NT ... WinSock has a common provider DLL called MSAFD.DLL. ... AFD.SYS is a kernel module which implements the sockets semantics on top of ... This will give you lots of socket stuff, ...
    (microsoft.public.win32.programmer.kernel)