Re: CSocket stops receiving



On Aug 6, 1:25 pm, "Michael K. O'Neill"
<MikeAThon2...@xxxxxxxxxxxxxxxxxx> wrote:
<SKolchu...@xxxxxxxxx> wrote in message

news:1186426641.904966.215290@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



I have a problem which I am finding myself unable to figure out.

I have a fairly simple CSocket-derived class, which does not much
beyond overriding OnReceive so that it saves all the received buffer,
and then calling a function of a Pointer to a thread class of mine,
which does what it will with the buffer.

At the moment I have a server and a client, both of which have a
thread for receiving and a thread for sending through these sockets.
The general communication type is thus - client sends a request,
server processes and sends some sort of a reply. The messages to be
sent in-process are delivered through inter-thread messaging.

The problems occurs mainly while debugging, but it can happen while
just running the applications - at some point, if a number of request
are "fired" rapidly, the connection get messed up in a rather odd way:

Clients sends successfully, then Server receives, does it's
processing, goes on to send a reply, the send operation goes without
errors, and yet the other side never receives the message. I've traced
all the receive calls on my socket class, and not once there was an
error.
So basically, everything indicates that the connection is alive, and
yet it never goes through in one direction.

The messages are of varied sizes, but when in debug, 2 140-bytes
requests and 160-bytes replies kill the communication.

In your OnReceive handler, so you call Receive() more than once? Calling
Receive more than exactly once in the OnReceive handler can cause loss of
future FD_READ notifications, leading to the symptoms you are seeing.

Yes, I do just that, but I need to read the message length first
before receiving it all. Would a Receive() call with PEEK help this,
or receiving the whole buffer at once is the better option here?

.



Relevant Pages

  • Re: pushing the envelope with sockets
    ... receiving on the socket they are received (upto the buffer size), you can even change what happens if the buffer runs full. ... int read = S.EndReceive; ... class AsyncReader: Reader ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Fundamentals question, is this how it works?
    ... Note the packet may be partially received when you get ... That is what i thought i was saying that it receives it all in a stream ... receving the buffer size each time. ... receiving that many bytes i then break and wait for the next set of data ...
    (microsoft.public.win32.programmer.networks)
  • Re: CAsyncSocket and Send
    ... I'm also sending/receivingbinary data (file transfer). ... which usually is less than a full buffer). ... >> Are you using TCP/IP or UDP? ... >>>in C and the receiving side is MFC. ...
    (microsoft.public.vc.mfc)
  • Re: Fundamentals question, is this how it works?
    ... processing packets after you are done with one. ... receving the buffer size each time. ... TCP is a stream-based protocol, which means that it ignores any attempt ... then the receiving side might get ...
    (microsoft.public.win32.programmer.networks)
  • Re: pushing the envelope with sockets
    ... so it would seem 2.0 does indeed buffer UDP. ... Using async I/O ... receiving on the socket they are received, ... Okay, so during *one* run, the cpu spent increases when input-data is ...
    (microsoft.public.dotnet.languages.csharp)