Author | Message | Time |
---|---|---|
l2k-Shadow | Alright, well I'm making a filter gateway for battle.net clients, so that instead of client->server connection it goes client->gateway->server... and it's giving me a problem of the client receiving the data sent by my program multiple times: [img]http://www.l2uthlessnet.com/ss2.png[/img] My code for receiving Battle.net data: [code] Private Sub wsBNET_DataArrival(ByVal bytesTotal As Long) Static Buffer As String Dim Data As String, Length As Long Call wsBNET.GetData(Data, vbString, bytesTotal) Buffer = Buffer & Data While Len(Buffer) >= 4 Length = GetWORD(Mid$(Buffer, 3, 2)) If Length > Len(Buffer) Then Exit Sub Call ParseRecvData(Buffer) Buffer = Mid$(Buffer, Length + 1) Wend End Sub [/code] Code for ParseRecvData(): [code] Public Sub ParseRecvData(ByVal Data As String) Select Case Asc(Mid$(Data, 2, 1)) Case &HA: Con.Username = TrimString(Mid$(Data, 5)) Case &H50: Con.ServerToken = GetDWORD(Mid$(Data, 9, 4)) Con.MPQNumber = CInt(Mid$(Data, 32, 1)) Con.HashValue = TrimString(Mid$(Data, 38)) End Select Call frmMain.wsListen.SendData(Data) End Sub [/code] Any ideas? I tried using DoEvents and checking if the Data was already sent by the socket but it still happens... any input is appreciated. Thanks. | February 18, 2006, 4:12 AM |
Ringo | Ah, i had this problem a few times, i think it was because of the static string. (I take it this only happens now and then?) try: [code] Private Sub wsBNET_DataArrival(ByVal bytesTotal As Long) Static Buffer As String Dim Data As String, Length As Long Call wsBNET.GetData(Data, vbString, bytesTotal) Buffer = Buffer & Data While Len(Buffer) >= 4 Length = GetWORD(Mid$(Buffer, 3, 2)) If Length > Len(Buffer) Then Exit Sub Data = left(Buffer, lengh) Call ParseRecvData(Data) buffer = mid(buffer, 1 + lengh) Wend End Sub [/code] Hope this helps | February 18, 2006, 4:15 AM |
l2k-Shadow | omg Ringo you rock. thanks much.. although I still don't understand why it happens in the first place.. I guess another gay VB thing. | February 18, 2006, 5:05 AM |