Results 1 to 9 of 9

Thread: Missing DataArrival * resolved

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Missing DataArrival * resolved

    When I run the program without break there's a missing data arrival (I kept track by adding the Index to a string every time DataArrival fires, I compared it to a similar string for sends). But when I stepped through it with breakpoints to find the error, everythings accounted for.

    Also, after running without breakpoints, I then pause execution and resume. The missing DataArrival gets fired. Weird.

    Anybody have an idea?
    Last edited by leinad31; May 1st, 2003 at 10:05 AM.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    Seems to be because of my broadcast function. Is anything wrong with it?

    VB Code:
    1. Public Sub SendBroadcast_sckTCP(SendDgram As Dgram_Unit, ExceptIndex As Integer)
    2.  
    3.    Dim objSocket As Winsock
    4.    
    5.    For Each objSocket In frmCommon.sckTCP
    6.       If objSocket.Index > 0 And objSocket.State = sckConnected _
    7.       And objSocket.Index <> ExceptIndex Then
    8.          Call Send_sckTCP(SendDgram, objSocket.Index)
    9.       End If
    10.    Next
    11. End Sub

    Send_sckTCP() works fine.

  3. #3
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    The data might be getting bunched up or something.
    Actually, you're referring to datagrams. Are you using UDP ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    With names in his code like "Send_sckTCP()", I get the feeling it aint UDP.

    Make sure on your data arrival that your code is collecting all the data, I have never had the problem of missing any but i know some people like to use loops counting the bytes recieved and the bytes that winsock has put in the string. you compare them and loop until the length of the string matches what winsock says has arrived.

    I am not at my computer so I cannot make you an accurrate code attempt.

  5. #5
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Originally posted by Spajeoly
    With names in his code like "Send_sckTCP()", I get the feeling it aint UDP.
    Except most people refer to IP as TCP/IP, and as such UDP would be a component of TCP/IP
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  6. #6
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    Don't go getting technical on me now Mister! What do you thinkg this is, a technically related message board?

  7. #7
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Originally posted by Spajeoly
    Don't go getting technical on me now Mister! What do you thinkg this is, a technically related message board?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    Thanks for replying guys. Thought no one would.

    I used Dgram for lack of any better description, since it isn't a packet, nor frame, the protocol is TCP/IP. I was able to make the broadcast work with DoEvents. At first I thought it was because I passed the socket property as a parameter but storing first in a variable didn't work. Strangely this worked.

    VB Code:
    1. Public Sub SendBroadcast_sckTCP(SendDgram As Dgram_Unit, ExceptIndex As Integer)
    2.  
    3.    Dim X As Long
    4.    Dim objSocket As Winsock
    5.    Dim SendTo As Broadcast_SentToUnit
    6.    
    7.    SendTo.A_AddIndex = -1
    8.    ReDim SendTo.B_SentToInfo(0)
    9.    For Each objSocket In frmCommon.sckTCP
    10.       If objSocket.Index > 0 And objSocket.Index <> ExceptIndex _
    11.       And objSocket.State = sckConnected Then
    12.          SendTo.A_AddIndex = SendTo.A_AddIndex + 1
    13.          ReDim Preserve SendTo.B_SentToInfo(SendTo.A_AddIndex)
    14.          SendTo.B_SentToInfo(SendTo.A_AddIndex).A_SocketIndex = objSocket.Index
    15.          SendTo.B_SentToInfo(SendTo.A_AddIndex).B_IPAddress = objSocket.RemoteHostIP
    16.       End If
    17.    Next
    18.    
    19.    For X = 0 To SendTo.A_AddIndex
    20.       If Find_sckTCP(SendTo.B_SentToInfo(X).A_SocketIndex) > 0 Then  'Check if still exists.
    21.          Call Send_sckTCP(SendDgram, SendTo.B_SentToInfo(X).A_SocketIndex)
    22.       End If
    23.       DoEvents
    24.    Next
    25.      
    26. End Sub

    Admittedly its making things more complicated than it should be but as long as it works. BTW, just putting DoEvents in the earlier code didn't work because the socket sometimes gets unloaded before processing returns to the procedure.
    Last edited by leinad31; May 1st, 2003 at 10:31 AM.

  9. #9
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    Sweet, well just incase, here's that data arrival a guy suggest I use anytime working with winsock, though I don't use it but hey lol.

    VB Code:
    1. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    2. Dim strdata, getit As String
    3. Dim bytesRec As Long
    4. bytesRec = 0
    5. strdata = ""
    6.  
    7. Do While bytesTotal > bytesRec
    8.     Winsock1.GetData getit, vbString, bytesTotal
    9.     strdata = strdata & getit
    10.     bytesRec = bytesRec + Len(strdata)
    11.     DoEvents
    12. Loop
    13.  
    14. End Sub

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