Re: Multithread safety

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



> Not sure what you mean by exclusively but yes you can read and write
> simultaneously.
> When discussing multi-threading it is important to first determine what is
a
> shared "resource" that you are accessing. In case of a TCP socket there
are
> 3 of them
>
> 1. The socket object itself
> 2. The input TCP stream
> 3. The output TCP stream.
>
> The socket object is thread safe. When you call recv() and send()
> simultaneously nothing in the socket internal data structures will break.
> The streams are separate resources so again recv() on one and send() on
> another are ok.
> What is usually not ok is two simultaneous recv()-s or send()-s. They
access
> the same stream object and any stream is not safe for multiple reads or
> writes.
>

This is exactly what I needed to know.. thank you for your detailed answer !

Mike



.



Relevant Pages

  • Re: Flush recv buffer
    ... Obviously, you could just close the socket, or simply recv the ... One nanosecond after you decide you've drained the stream, ... reading and processing subsequent messages. ...
    (comp.unix.programmer)
  • Re: question about how to use send() and recv()
    ... > If I have a 1024 byte send buffer and I know my application will never ... pieces and send them individually (for stream sockets) and it might ... not grab all your data at once, so you must loop. ... > buffer off to recv(), does the sockets library keep trying to receive ...
    (comp.unix.programmer)
  • Re: SslStream weakness
    ... stream, however, it's important that you correctly close the SSL stream ... before the TCP stream, or else it would be relatively easy for an attacker ... FTP is one example of such a protocol. ...
    (microsoft.public.platformsdk.security)
  • Re: wierd send/recv problem
    ... Now how about the receiver code....how should that work?? ... If you want message boundaries to know ... Do you mean that I'll have to call recv again to receive the message ... stream of bytes - it knows no "message" boundaries. ...
    (microsoft.public.win32.programmer.networks)
  • Re: wierd send/recv problem
    ... Now how about the receiver code....how should that work?? ... you will need to encode the boundaries in your ... Do you mean that I'll have to call recv again to receive the message if ... stream of bytes - it knows no "message" boundaries. ...
    (microsoft.public.win32.programmer.networks)