IOCP question: ordering of data

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi,

I'm messing around with TCP programming using iocps (XP Pro)

If multiple iocp-worker threads are used, how data-corruption can be avoided.

Example:

- Thread #1 WSASends a block of data.
This send could not completely be done by winsock, so the completion
notification comes back with according byte counts, (bytes_sended <
bytes_to_be_sended).

Thread #1 tries to WSASend the rest of the data-block

- just before issuing the WSASend, Thread #1 is preempted by Thread #2
Thread #2 WSASends another block of data.
Here data corruption may/will occur.

In such a scenario (it is never guaranteed that winsock is able to send all data of a WSASend-Call, the app may be required to re-send the rest)
how can multiple threads work properly?
My understanding is that if I issue only ONE WSASend on one socket, data integrity can be guaranteed.
This implies that multiple sends issued from multiple threads to one socket does not make sense. Multiple sends from one thread would be ok.
But then there is no advantage using multiple threads...
.



Relevant Pages

  • Re: IOCP question: ordering of data
    ... WSASend will never return with a partial ... Microsoft MVP, MCSD ... If multiple iocp-worker threads are used, ... My understanding is that if I issue only ONE WSASend on one socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: IOCP question: ordering of data
    ... A good example of such is iocp sample in PSDK which use additional ... WSASend will never return with a partial ... If multiple iocp-worker threads are used, ... My understanding is that if I issue only ONE WSASend on one socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: IOCP question: ordering of data
    ... in theory WSASend can do partial writes for blocking ... Microsoft MVP, MCSD ... If multiple iocp-worker threads are used, ... My understanding is that if I issue only ONE WSASend on one socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: IOCP question: ordering of data
    ... WSASend will never return with a partial ... If multiple iocp-worker threads are used, ... In such a scenario (it is never guaranteed that winsock is able to send ... My understanding is that if I issue only ONE WSASend on one socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: SetSockOpt with SO_REUSEADDR parameter
    ... no concept that allows you to create multipe sockets with the same port number. ... happening is that you are throwing away the old socket and replacing it with the new ... That is not the same as creating multiple sockets with the same port #. ... Because I will send real-time video frame, I use UDP socket. ...
    (microsoft.public.vc.mfc)