Re: Sockets Beginreceive not working correctly.
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Tue, 20 Jan 2009 15:36:35 -0800
On Tue, 20 Jan 2009 15:19:16 -0800, David <nospam@xxxxxxxx> wrote:
I'm using Sockets to send a receive data. My issue is when I open up a
socket, I can send and receive data correctly the first try. Upon the
second try without closing anything, I send some data, but receive nothing.
There are two likely possibilities:
-- By the time you get to stepping through the code, all of the data you sent has been sent. In which case, it will all have been received by your first receive (assuming the buffer's big enough).
-- By the time you get to stepping through the code, the second part of your data hasn't yet been sent.
In either case, there's no reason to expect your callback method to be executed.
I noticed as I step through the code, during the second receive, I execute
the client.BeginReceive but the debugger goes to the next line without going
into the callback function, as if that Client.BeginRecieve line isn't there.
No errors occur.
BeginReceive() would not normally execute the callback in any case. The normal use case involves BeginReceive() returning immediately, and your callback being executed at some later time, when there's actually data to be received.
Anyone have any ideas, what that maybe. Would I have some something blocking
from the first receive?
Without a concise-but-complete code sample, it's impossible to say for sure why your expectations are incorrect. However, suffice to say that the likelihood of it actually being the case that "Beginreceive [sic] not working correctly" is practically non-existent. You are surely doing something wrong.
By the way, one thing I can see from your code that you're definitely doing wrong is using a new Encoding instance each time you receive more data. You should be calling GetDecoder() and using the one Decoder you get each time you receive bytes, so that it can correctly deal with multi-byte characters that might have gotten split up during transmission.
Pete
.
- Follow-Ups:
- Re: Sockets Beginreceive not working correctly.
- From: David
- Re: Sockets Beginreceive not working correctly.
- References:
- Sockets Beginreceive not working correctly.
- From: David
- Sockets Beginreceive not working correctly.
- Prev by Date: Re: Access keys do not show underlined character
- Next by Date: Re: Multi-line GroupBox text?
- Previous by thread: Sockets Beginreceive not working correctly.
- Next by thread: Re: Sockets Beginreceive not working correctly.
- Index(es):
Relevant Pages
|