Socket EndReceive issues

G

Guest

I have a Socket based application using the asynchronous Sends and Receives
of the Socket class. I send out XML strings using BeginSend/EndSend from a
client end point, the server side does a BeginReceive/EndReceive.

I knew a message could be split up between Receives and I look for an end of
message marker (and continue receiving if not there) before processing the
complete message. However I was told (on this board I think) that I would not
have to deal with multiple messages in one packet. That is, I wouldn't get
[Message1]<EOM>[Message2] in the same Receive Buffer.

But that is exactly what I'm seeing. I can code for this if thats to be
expected, but I wanted to know if this is a sign of a bug, or this is really
what should/could happen with asynchronous Sockets.

Should I assume that a Receive on a given socket from a given RemoteEndpoint
is not separate and distinct messages but a continuous message stream where
one message could be broken up across multiple packets AND multiple messages
(or parts of messages) may show up in one packet?

Thanks,
Ken
 
G

Guest

I posted this to both vb.net and csharp.net communities. In the csharp
community someone responded that, yes, it is a stream and therefore can have
multiple messages in it. (i paraphrased quite a bit there).

I can code for that knowing thats what it is, but my question is, is the
stream specific to a given client and server (ie.
localEndPoint/RemoteEndPoint connection)? If I have several clients connected
to the same server port, no two clients will send messages on the same
stream, but a given client could send multiple messages on it's stream. Is
that the gist of the idea?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top