Click here to Skip to main content
15,921,028 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralA problem! Pin
wabc6-Feb-02 13:58
wabc6-Feb-02 13:58 
GeneralRe: A problem! Pin
Christian Graus6-Feb-02 14:24
protectorChristian Graus6-Feb-02 14:24 
QuestionCAsyncSocket will recv all packets in one recv? Pin
AnonymousBabe@usa.net6-Feb-02 13:49
AnonymousBabe@usa.net6-Feb-02 13:49 
AnswerRe: CAsyncSocket will recv all packets in one recv? Pin
Tim Smith6-Feb-02 15:27
Tim Smith6-Feb-02 15:27 
GeneralRe: CAsyncSocket will recv all packets in one recv? Pin
AnonymousBabe@usa.net6-Feb-02 16:32
AnonymousBabe@usa.net6-Feb-02 16:32 
GeneralRe: CAsyncSocket will recv all packets in one recv? Pin
markkuk6-Feb-02 20:35
markkuk6-Feb-02 20:35 
AnswerRe: CAsyncSocket will recv all packets in one recv? Pin
AnonymousBabe@usa.net6-Feb-02 21:33
AnonymousBabe@usa.net6-Feb-02 21:33 
GeneralRe: CAsyncSocket will recv all packets in one recv? Pin
6-Feb-02 22:16
suss6-Feb-02 22:16 
The class is working fine. As markuk pointed out, TCP/IP is a stream based protocol, and not packet based.

In practical terms, what this means is that you will not receive packets in the client but bytes. Theoretically, in your example you could even receive 1 byte at a time (agreed that it is unlikely), but by calling recv repeatedly you will eventually receive all of the bytes that you sent, and in the same order.

So, whether the server sends "aaa" followed by "bbb" followed by "ccc", TCP/IP will treat it exactly the same as if it had sent each letter individually as "a","a","a","b","b","b","c","c","c" or even all together as "aaabbbccc". These are NOT indivdual packets but just bytes within the stream.

What you need, as a very simple solution, is to place a 'framing' character within the stream that indicates the end of each individual message. For example, write a zero into the stream after each message. You will have to modify the client to break the stream back into messages by scanning for these zero bytes. Don't forget that TCP/IP will only give the client the part of the message that has so far been received - sometimes you will have to wait for the zero byte to arrive.

Hope this helps.... Good luck with your code Smile | :)

Dhar
GeneralRe: CAsyncSocket will recv all packets in one recv? Pin
Peter Weyzen7-Feb-02 10:10
Peter Weyzen7-Feb-02 10:10 
Generalconverting Pin
6-Feb-02 13:26
suss6-Feb-02 13:26 
GeneralRe: converting Pin
Christian Graus6-Feb-02 13:51
protectorChristian Graus6-Feb-02 13:51 
GeneralRe: converting Pin
Paul M Watt6-Feb-02 14:21
mentorPaul M Watt6-Feb-02 14:21 
GeneralRe: converting Pin
Paul M Watt6-Feb-02 18:13
mentorPaul M Watt6-Feb-02 18:13 
GeneralRe: converting Pin
Tim Smith6-Feb-02 15:05
Tim Smith6-Feb-02 15:05 
GeneralMoving Controls on a Dialog Pin
John Clump6-Feb-02 12:31
John Clump6-Feb-02 12:31 
GeneralRe: Moving Controls on a Dialog Pin
Joaquín M López Muñoz6-Feb-02 12:35
Joaquín M López Muñoz6-Feb-02 12:35 
GeneralRe: Moving Controls on a Dialog Pin
John Clump6-Feb-02 14:48
John Clump6-Feb-02 14:48 
GeneralRe: Moving Controls on a Dialog Pin
Josh Koppang6-Feb-02 12:42
Josh Koppang6-Feb-02 12:42 
GeneralRe: Moving Controls on a Dialog Pin
Josh Koppang6-Feb-02 12:49
Josh Koppang6-Feb-02 12:49 
GeneralRe: Moving Controls on a Dialog Pin
John Clump6-Feb-02 16:19
John Clump6-Feb-02 16:19 
GeneralRe: Moving Controls on a Dialog Pin
Josh Koppang6-Feb-02 23:39
Josh Koppang6-Feb-02 23:39 
GeneralRe: Moving Controls on a Dialog Pin
John Clump7-Feb-02 17:46
John Clump7-Feb-02 17:46 
GeneralRe: Moving Controls on a Dialog Pin
jagadish bharath2-Aug-02 0:47
jagadish bharath2-Aug-02 0:47 
GeneralFirst word Pin
6-Feb-02 12:05
suss6-Feb-02 12:05 
GeneralRe: First word Pin
Michael Dunn6-Feb-02 12:03
sitebuilderMichael Dunn6-Feb-02 12:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.