WInsock SendData problem HELP 
Author Message
 WInsock SendData problem HELP

I am building a client server application using Winsock
control.
The server side is sending data in a list box then I need
to retrive those
data in the client side also in a list box.
The server side is  using Additems methods in order to get
each entry on
each line.

The client server connection works fine except that when
the client receive
the event DataArrival and use GetData to retrive
information then those
data when added to the client list box appears on the same
line.

The tcpClient_DataArrival function looks like this :

Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String

    tcpClient.GetData strData
    listEvent.AddItem strData

End Sub

At this point when AddItem is executed everything is
written in list box on
a single line.

Sounds like DataArrival event is not fire fast enough than
Server Send Data is executed.
If I send data one by one from a button click it works ok
but as soon as I am in a loop then it is not working.

IN other words if I send
 "123"
 "456"
 "789"

I retrieve "123456789"

Any idea how to solve that ?
Thanks for your help



Tue, 25 May 2004 16:17:17 GMT  
 WInsock SendData problem HELP
Hmm ...

It should not be a Problem actually ...
After WinSock Connection is complete and both sides are in TRansaction mode
the Data Transfer happens almost instanteneously ( provided you network
traffic is not too heavy !!! ).

Is this the loop on the Server side ( from where you are sending the date ),

for i = 1 to 5
    tcpServer.SendData (i + 200)            'e.g. 201, 202, 203 ....
next i

If yours is this kind of loop then there is not supposed to be any problem.

If you think that the Winsock is getting slow in DataArrival Response you
can make the Server wait after sending some data.
You can fire winsock_sendComplete to check if the initial Transfer is
complete and then go on for next value in the Loop.

e.g. declare a Boolean
Dim transferComplete as Boolean

Private Sub sendThis()
    For i = 1 To 5
        tcpServer.SendData (i + 200)            'e.g. 201, 202, 203 ....

        Do While transferComplete <> True
            'Wait till the WinSock Fires the SendComplete event and Changes
the Flag to True
            'Reset the Flag to False for next check.
            transferComplete = False
        Loop
    Next i
End Sub

'The SendComplete method goes as follows ...
Private Sub Winsock_SendComplete()
    transferComplete = true
End Sub

I'vent tested winsock this way but i'm sure this will work ...

rgrds ,

Max


Quote:
> I am building a client server application using Winsock
> control.
> The server side is sending data in a list box then I need
> to retrive those
> data in the client side also in a list box.
> The server side is  using Additems methods in order to get
> each entry on
> each line.

> The client server connection works fine except that when
> the client receive
> the event DataArrival and use GetData to retrive
> information then those
> data when added to the client list box appears on the same
> line.

> The tcpClient_DataArrival function looks like this :

> Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
> Dim strData As String

>     tcpClient.GetData strData
>     listEvent.AddItem strData

> End Sub

> At this point when AddItem is executed everything is
> written in list box on
> a single line.

> Sounds like DataArrival event is not fire fast enough than
> Server Send Data is executed.
> If I send data one by one from a button click it works ok
> but as soon as I am in a loop then it is not working.

> IN other words if I send
>  "123"
>  "456"
>  "789"

> I retrieve "123456789"

> Any idea how to solve that ?
> Thanks for your help



Tue, 25 May 2004 17:50:43 GMT  
 WInsock SendData problem HELP
Thnaks for your proposal I will give a try.
I have an other question by the way.
How can I handle a real sychronisation between the server
and the client. This in order to get feed back from the
server that it has really accepted the connection or
detect that a connection is down from client or server
side.

Do i have to use the same SendData method for that or
should I use an other insatnce of the winsock control
dedicated fro handshaking?

thanks for your help
Regards
Serge

Quote:
>-----Original Message-----
>Hmm ...

>It should not be a Problem actually ...
>After WinSock Connection is complete and both sides are
in TRansaction mode
>the Data Transfer happens almost instanteneously (

provided you network
Quote:
>traffic is not too heavy !!! ).

>Is this the loop on the Server side ( from where you are
sending the date ),

>for i = 1 to 5
>    tcpServer.SendData (i + 200)            'e.g. 201,
202, 203 ....
>next i

>If yours is this kind of loop then there is not supposed
to be any problem.

>If you think that the Winsock is getting slow in

DataArrival Response you
Quote:
>can make the Server wait after sending some data.
>You can fire winsock_sendComplete to check if the initial
Transfer is
>complete and then go on for next value in the Loop.

>e.g. declare a Boolean
>Dim transferComplete as Boolean

>Private Sub sendThis()
>    For i = 1 To 5
>        tcpServer.SendData (i + 200)            'e.g.
201, 202, 203 ....

>        Do While transferComplete <> True
>            'Wait till the WinSock Fires the SendComplete
event and Changes
>the Flag to True
>            'Reset the Flag to False for next check.
>            transferComplete = False
>        Loop
>    Next i
>End Sub

>'The SendComplete method goes as follows ...
>Private Sub Winsock_SendComplete()
>    transferComplete = true
>End Sub

>I'vent tested winsock this way but i'm sure this will
work ...

>rgrds ,

>Max


in message

>> I am building a client server application using Winsock
>> control.
>> The server side is sending data in a list box then I
need
>> to retrive those
>> data in the client side also in a list box.
>> The server side is  using Additems methods in order to
get
>> each entry on
>> each line.

>> The client server connection works fine except that when
>> the client receive
>> the event DataArrival and use GetData to retrive
>> information then those
>> data when added to the client list box appears on the
same
>> line.

>> The tcpClient_DataArrival function looks like this :

>> Private Sub tcpClient_DataArrival(ByVal bytesTotal As
Long)
>> Dim strData As String

>>     tcpClient.GetData strData
>>     listEvent.AddItem strData

>> End Sub

>> At this point when AddItem is executed everything is
>> written in list box on
>> a single line.

>> Sounds like DataArrival event is not fire fast enough
than
>> Server Send Data is executed.
>> If I send data one by one from a button click it works
ok
>> but as soon as I am in a loop then it is not working.

>> IN other words if I send
>>  "123"
>>  "456"
>>  "789"

>> I retrieve "123456789"

>> Any idea how to solve that ?
>> Thanks for your help

>.



Fri, 28 May 2004 15:41:01 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VB6: Winsock senddata problem - help!

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

3. winsock senddata problem/question

4. Winsock.SendData Problem

5. problem with winsock.senddata

6. Visual Basic Winsock senddata problem

7. Winsock TCP SendData problem

8. problem with WINSOCK.SENDDATA

9. Winsock SendData problems

10. Winsock SendData Problem?

11. Winsock SendData problem

12. senddata method problem in winsock control

 

 
Powered by phpBB® Forum Software