Hi,
I am facing probs of senddata not working sometimes. Is there any reason for this. Does anybody has faced same probs?
Thanks.
Printable View
Hi,
I am facing probs of senddata not working sometimes. Is there any reason for this. Does anybody has faced same probs?
Thanks.
What are you trying to send? Are you recieving on the other end correctly...?
Situatuation is - a user logs. On server program i'm maintaining collection of all current users. Now if same username logs in again from diff IP, i want to show the message to previous one and then to disconnect it. But at no cost its sending the message to prev one. Message is going to new one.
Thanks
So, when people login to your server application, they stay connected? Are you using a Winsock control array or API?
It a complete messaging application with winsock (obviously thats y i'm facing probs with senddata).
I've used control array.
Thanks
Sounds like you are using the SendDatas in a For Next loop to loop through the elements in the control array...
VB Code:
For i = 1 to UBound(Winsock1) Winsock1.SendData "data" Next
The problem when something like the above is used, data might not have been phyiscally sent out of the computer before the loop comes around a second time and invokes the next SendData. This can be due to network congestion, etc, etc..
Winsock will get around this by sticking the two strings to send together and send them as one, even if the two recipients are different (only one recipient will receive it). Thus, this will give you your only the 'newest' connected machine will receieve the data.
The most foolproof way to get around this is to use the SendComplete event. That is, you wait for the SendComplete event to fire before invoking the next SendData, like below:
VB Code:
Option Explicit Private DataSent As Boolean Private Sub YourSub() Dim i As Integer For i = 1 To UBound(Winsock) DataSent = False Winsock(b).SendData "data" WaitComplete Next i End Sub Private Sub WaitComplete() Do Until DataSent = True DoEvents Loop End Sub Private Sub Winsock_SendComplete(Index As Integer) DataSent = True End Sub
Thanks dear. Let me implement this and then i'll getback to you with results.
Bye