Asynchronous socket programming
-
at to fast message sending i get 1 incoming message with 10 grouped packets and not 1 packet for each of 10 incoming messages for p.s. sry for terrible english
I am not sure what the 1 message with 10 packets means... specially compared to 1 packet to 10 messages, but I think I have the "solution". For example: Send("Test1"); Send("Test2"); Send("Test3"); The client can receive: Test1Test2Test3 Or you can receive the message as: Test 1Tes t2Te st3 In fact, TCP/IP only "streams" data. If you expect to send "one packet" and receive "one packet" you are going the wrong way. Ahh... and that's has nothing to do with synchronous or asynchronous programming... it's the TCP/IP way of working. If you expect for messages, you must Receive the buffer, accumulate it to the last buffer (if it exists) and then search as many "begin/ends" as it is possible in the message, so it's up to you to do that.
-
I am not sure what the 1 message with 10 packets means... specially compared to 1 packet to 10 messages, but I think I have the "solution". For example: Send("Test1"); Send("Test2"); Send("Test3"); The client can receive: Test1Test2Test3 Or you can receive the message as: Test 1Tes t2Te st3 In fact, TCP/IP only "streams" data. If you expect to send "one packet" and receive "one packet" you are going the wrong way. Ahh... and that's has nothing to do with synchronous or asynchronous programming... it's the TCP/IP way of working. If you expect for messages, you must Receive the buffer, accumulate it to the last buffer (if it exists) and then search as many "begin/ends" as it is possible in the message, so it's up to you to do that.