Re: CSocket stops receiving
- From: Slava K <SKolchurin@xxxxxxxxx>
- Date: Tue, 07 Aug 2007 13:44:45 -0000
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?
.
- Follow-Ups:
- Re: CSocket stops receiving
- From: Michael K. O'Neill
- Re: CSocket stops receiving
- References:
- CSocket stops receiving
- From: SKolchurin
- Re: CSocket stops receiving
- From: Michael K. O'Neill
- CSocket stops receiving
- Prev by Date: Re: MFC and number of times COM intialized
- Next by Date: Re: I ask question for the thread
- Previous by thread: Re: CSocket stops receiving
- Next by thread: Re: CSocket stops receiving
- Index(es):
Relevant Pages
|