Re: Socket switch delay

From: mil (mil_at_discussions.microsoft.com)
Date: 08/24/04


Date: Tue, 24 Aug 2004 12:21:14 -0700


"Alexander Nickolov" wrote:

>(and I noticed you don't do overlapped receive at the server!)

The receive operation in the server is overlapped, first I receive a header
which describes what is coming (with one recv competion io) and then I setup
buffers and wait for all the data I should be receiving, through the
completion IO. If not all the data comes back, I calculate the right offsets
and wait again for the completion io.

I didn’t send you that part of the code because it is too long.

>would you set the send buffer size to zero on a non-overlapped
>socket escapes me...).

So I get better performance(?) Since I am sending all the data at once using
WSA buffers why do I need to copy them again? Of course I changed that in the
server (so the user can disable the 0 buffering, maybe I should make it
optional in the client too).

>One glaring error is your client does not check it sent all data in one go

Hmm, you are right. I thought when I send data it always sends them all or
it returns an error. I also thought that only the receive can send partial
buffers where the send always sends the whole thing or nothing.

I think I got this whole thing wrong.

>though I have no idea if this is your problem. So when you use a >single socket, what exactly happens with this code and on which >side?

If the previous assumption of mine, is wrong, then that must be the problem.
Because when the client sends data while the server also sends data, the
connection fails and the server socket stays locked for a minute or two.

>Finally, I've never mixed overlapped with non-overlapped I/O
>on the same socket. Could that be your problem?

I didn’t mix the two models, only the client is not using Overlapped IO. The
server is using it for all communication and file writing.

The problem must be the fact that I don’t “expect” the send command to send
partial buffers. And I am not taking into account that in both the client and
the server code. Where for the receive, I “obey” the rules.

So only when I am using a single socket and both client and server are
sending data, the send-operation does not send all the buffers in one go and
“asks me” to try again (and my code doesn’t handle this condition).

I am not saying that this cannot happen with the current code as well, but
it seems that it mostly happens when both sides try to talk over the same
socket.

I will change the code accordingly to take this into account at both sides.

Thanks for pointing out all these “omissions” (to put it kindly) in my code ;)

Now back to the drawing board for me :( I am going to add the checking for
the send operations in client and server then try again with a single socket.

mil



Relevant Pages

  • Re: Socket switch delay
    ... both at the client and at the server (and why ... would you set the send buffer size to zero on a non-overlapped ... One glaring error is your client does ... So when you use a single socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Socket switch delay
    ... buffers are queued and will be later sent. ... socket, not sure about a blocking socket. ... >>(and I noticed you don't do overlapped receive at the server!) ... > optional in the client too). ...
    (microsoft.public.win32.programmer.networks)
  • Re: Locking on async calls
    ... you must synchronize the entire SendMessage routine as an atomic ... operation to prevent mixed messages from being transmitted to the server. ... You are correct that read and write on the socket do not interfere with each ... If you want to handle multiple client connections from one server object ...
    (microsoft.public.dotnet.general)
  • Re: socket communication: socket doesnt connect
    ... Microsoft MVP, MCSD ... As far as your server code goes, ... accept the listening socket. ... Client client = new Client; ...
    (microsoft.public.vc.language)
  • Re: TCP server stop receiving new connections
    ... reset the event mask of your listening socket each time you ... I have a strange problem in my class library used by all our client ... server applications. ... incomming connections, but keeps current connections. ...
    (microsoft.public.win32.programmer.networks)

Loading