|
-
Oct 27th, 2001, 06:18 AM
#1
Thread Starter
Addicted Member
Winsock senddata
Hi,
I am facing probs of senddata not working sometimes. Is there any reason for this. Does anybody has faced same probs?
Thanks.
-
Oct 27th, 2001, 06:20 AM
#2
Fanatic Member
Questions...
What are you trying to send? Are you recieving on the other end correctly...?
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
-
Oct 27th, 2001, 06:26 AM
#3
Thread Starter
Addicted Member
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
-
Oct 27th, 2001, 06:53 AM
#4
Fanatic Member
Questions...
So, when people login to your server application, they stay connected? Are you using a Winsock control array or API?
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
-
Oct 27th, 2001, 06:55 AM
#5
Thread Starter
Addicted Member
It a complete messaging application with winsock (obviously thats y i'm facing probs with senddata).
I've used control array.
Thanks
-
Oct 27th, 2001, 07:32 AM
#6
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
-
Oct 27th, 2001, 07:41 AM
#7
Thread Starter
Addicted Member
Thanks dear. Let me implement this and then i'll getback to you with results.
Bye
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|