|
-
Apr 29th, 2003, 12:01 PM
#1
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.
-
Apr 29th, 2003, 12:40 PM
#2
Seems to be because of my broadcast function. Is anything wrong with it?
VB Code:
Public Sub SendBroadcast_sckTCP(SendDgram As Dgram_Unit, ExceptIndex As Integer)
Dim objSocket As Winsock
For Each objSocket In frmCommon.sckTCP
If objSocket.Index > 0 And objSocket.State = sckConnected _
And objSocket.Index <> ExceptIndex Then
Call Send_sckTCP(SendDgram, objSocket.Index)
End If
Next
End Sub
Send_sckTCP() works fine.
-
Apr 30th, 2003, 03:04 AM
#3
Retired VBF Adm1nistrator
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]
-
Apr 30th, 2003, 04:10 AM
#4
Frenzied Member
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.
-
Apr 30th, 2003, 04:41 AM
#5
Retired VBF Adm1nistrator
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]
-
Apr 30th, 2003, 04:43 AM
#6
Frenzied Member
Don't go getting technical on me now Mister! What do you thinkg this is, a technically related message board?
-
Apr 30th, 2003, 04:44 AM
#7
Retired VBF Adm1nistrator
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]
-
May 1st, 2003, 09:54 AM
#8
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:
Public Sub SendBroadcast_sckTCP(SendDgram As Dgram_Unit, ExceptIndex As Integer)
Dim X As Long
Dim objSocket As Winsock
Dim SendTo As Broadcast_SentToUnit
SendTo.A_AddIndex = -1
ReDim SendTo.B_SentToInfo(0)
For Each objSocket In frmCommon.sckTCP
If objSocket.Index > 0 And objSocket.Index <> ExceptIndex _
And objSocket.State = sckConnected Then
SendTo.A_AddIndex = SendTo.A_AddIndex + 1
ReDim Preserve SendTo.B_SentToInfo(SendTo.A_AddIndex)
SendTo.B_SentToInfo(SendTo.A_AddIndex).A_SocketIndex = objSocket.Index
SendTo.B_SentToInfo(SendTo.A_AddIndex).B_IPAddress = objSocket.RemoteHostIP
End If
Next
For X = 0 To SendTo.A_AddIndex
If Find_sckTCP(SendTo.B_SentToInfo(X).A_SocketIndex) > 0 Then 'Check if still exists.
Call Send_sckTCP(SendDgram, SendTo.B_SentToInfo(X).A_SocketIndex)
End If
DoEvents
Next
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.
-
May 1st, 2003, 09:39 PM
#9
Frenzied Member
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:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strdata, getit As String
Dim bytesRec As Long
bytesRec = 0
strdata = ""
Do While bytesTotal > bytesRec
Winsock1.GetData getit, vbString, bytesTotal
strdata = strdata & getit
bytesRec = bytesRec + Len(strdata)
DoEvents
Loop
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|