Winsock Senddata method - confusing?! 
Author Message
 Winsock Senddata method - confusing?!

Hi,

I am using the winsock control on VB5 (client/server).

If I send data from the server to a user on two separate lines of code....

         sckServer(1).SendData "This is line 1"
         sckServer(1).SendData "This is line 2"

The client only get one dataarrival event fired with the above text on one
line.

Has anyone got any solutions to this if I need two events to be fired? (Ie
data sent on two separate lines)

Thanks,

Olli.



Fri, 09 Jun 2000 03:00:00 GMT  
 Winsock Senddata method - confusing?!

do it like this

dim tmp as string
tmp="this is line1"+vbCrlf+"this is line2"
winsock1.senddata tmp

the client will receive two lines, thats what u wanted

Quote:
>Hi,
>I am using the winsock control on VB5 (client/server).
>If I send data from the server to a user on two separate lines of code....
>         sckServer(1).SendData "This is line 1"
>         sckServer(1).SendData "This is line 2"
>The client only get one dataarrival event fired with the above text on one
>line.
>Has anyone got any solutions to this if I need two events to be fired? (Ie
>data sent on two separate lines)
>Thanks,
>Olli.



Sat, 10 Jun 2000 03:00:00 GMT  
 Winsock Senddata method - confusing?!

Quote:


>do it like this

>dim tmp as string
>tmp="this is line1"+vbCrlf+"this is line2"
>winsock1.senddata tmp

>the client will receive two lines, thats what u wanted

No it won't. The above code will only fire one data arrival event with only
one piece of data:

a string that looks like "this is line1€€this is line2"



Sun, 11 Jun 2000 03:00:00 GMT  
 Winsock Senddata method - confusing?!

Quote:

>Hi,

>I am using the winsock control on VB5 (client/server).

>If I send data from the server to a user on two separate lines of code....

>         sckServer(1).SendData "This is line 1"
>         sckServer(1).SendData "This is line 2"

>The client only get one dataarrival event fired with the above text on one
>line.

>Has anyone got any solutions to this if I need two events to be fired? (Ie
>data sent on two separate lines)

>Thanks,

>Olli.

That is the way Steam Sockets work. You may also receive the data in
four chunks. It is up to the receiver to establish the message
boundaries.
If you use DGram sockets, you can send and recieve on message
boundaries but the messages are not guaranteed to arrive.
Mike J.


Sun, 11 Jun 2000 03:00:00 GMT  
 Winsock Senddata method - confusing?!

Try Doevents between sends
Let me know if works.

Tenny



Tue, 13 Jun 2000 03:00:00 GMT  
 Winsock Senddata method - confusing?!

Try Doevents between sends
Let me know if works.

Tenny



Tue, 13 Jun 2000 03:00:00 GMT  
 Winsock Senddata method - confusing?!

Try Doevents between sends
Let me know if works.

Tenny



Tue, 13 Jun 2000 03:00:00 GMT  
 Winsock Senddata method - confusing?!

Try Doevents between sends
Let me know if works.

Tenny



Tue, 13 Jun 2000 03:00:00 GMT  
 Winsock Senddata method - confusing?!

While performing DoEvents() may cause the messages to go out in two
separate packets, it's a very kludgy thing to do and will not be
predictable from one machine to the next.  

The only reason this might work is because the TCP protocol will only
wait so long for subsequent data to include in the packet before sending
off the data.  Because the two lines of code are executed on top of each
other, the data will most likely get combined into a single packet.

Let's fix the problem, not the symptoms.


Quote:

> Try Doevents between sends
> Let me know if works.

> Tenny



Sat, 17 Jun 2000 03:00:00 GMT  
 Winsock Senddata method - confusing?!

Try posting only once.
Let me know if it works.

Quote:

>Try Doevents between sends
>Let me know if works.

>Tenny



Fri, 23 Jun 2000 03:00:00 GMT  
 Winsock Senddata method - confusing?!



Quote:
>If I send data from the server to a user on two separate lines of code....

>         sckServer(1).SendData "This is line 1"
>         sckServer(1).SendData "This is line 2"

>The client only get one dataarrival event fired with the above text on one
>line.

That's the way stream sockets work.  For efficiency most stacks
implement something called the Nagel algorithm which, if you supply it
a short chunk of data via SendData, will wait a while before sending
it in the hope that you'll supply more data and the two writes can be
combined and effeciently handled.

But that's not all.

You get no guarantee that the data will arrive in one or two (or three
or five) chunks, it arrives as it arrives and that's all there is to
it.  If the fact that you used two SendDatas is significant then you
need to supply some sort of an indicator that you can use on the
receiving end.  You could put CRLF between the lines, preceed them
with a byte count, etc.

Zane



Fri, 23 Jun 2000 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Winsock Senddata method - confusing?!

2. how to send structures in winsock senddata method?

3. senddata method problem in winsock control

4. SendData method for winsock control 6.0

5. winsock problem sending large strings (winsock.senddata)

6. SendData and Winsock control collection ?

7. winsock senddata problem/question

8. Weird thing with Winsock.SendData

9. Winsock.SendData

10. WinSock SendData Error

11. Winsock.SendData From a DLL

12. Winsock.SendData Problem

 

 
Powered by phpBB® Forum Software