Results 1 to 7 of 7

Thread: Winsock senddata

  1. #1

    Thread Starter
    Addicted Member flavorjatin's Avatar
    Join Date
    Sep 2001
    Location
    India
    Posts
    154

    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.
    Best Regards.

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Location
    UK.
    Posts
    728

    Question 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]

  3. #3

    Thread Starter
    Addicted Member flavorjatin's Avatar
    Join Date
    Sep 2001
    Location
    India
    Posts
    154
    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
    Best Regards.

  4. #4
    Fanatic Member
    Join Date
    Sep 2000
    Location
    UK.
    Posts
    728

    Question 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]

  5. #5

    Thread Starter
    Addicted Member flavorjatin's Avatar
    Join Date
    Sep 2001
    Location
    India
    Posts
    154
    It a complete messaging application with winsock (obviously thats y i'm facing probs with senddata).
    I've used control array.

    Thanks
    Best Regards.

  6. #6
    sunnyl
    Guest
    Sounds like you are using the SendDatas in a For Next loop to loop through the elements in the control array...

    VB Code:
    1. For i = 1 to UBound(Winsock1)
    2.     Winsock1.SendData "data"
    3. 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:
    1. Option Explicit
    2.  
    3. Private DataSent As Boolean
    4.  
    5. Private Sub YourSub()
    6.     Dim i As Integer
    7.    
    8.     For i = 1 To UBound(Winsock)
    9.        
    10.         DataSent = False
    11.         Winsock(b).SendData "data"
    12.         WaitComplete
    13.  
    14.     Next i
    15. End Sub
    16.  
    17. Private Sub WaitComplete()
    18.     Do Until DataSent = True
    19.         DoEvents
    20.     Loop
    21. End Sub
    22.  
    23. Private Sub Winsock_SendComplete(Index As Integer)
    24.     DataSent = True
    25. End Sub

  7. #7

    Thread Starter
    Addicted Member flavorjatin's Avatar
    Join Date
    Sep 2001
    Location
    India
    Posts
    154
    Thanks dear. Let me implement this and then i'll getback to you with results.

    Bye
    Best Regards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width