hi all,
i have been stuck at it quite a while, i did make a post about it but it was lost so, i have made my own client/server which uses a certain asc char and length of the data in its tcp data.....the server sends tcp data which reaches the client winsock control and then process it...
as i receive the data i split them up ...i have used chr(02) to mark the begining of my data and used the 9th byte to mark the length of the data
after i receive my data ..i use this code to process them.
to make the tcp data a little complicated i have used chr(02) in between my the tcp data that the server sends to the clientCode:Dim sPackS As Integer Dim sPackE As Integer Dim i As Integer Dim j As Integer Dim sLast As Integer Dim sType As DataTypes Dim sData As String Dim sAllData As String Dim sLength As String For i = 1 To Len(iData) ' loop around each character If Mid(iData, i, 1) = "chr(02)" Then ' find the character char(02) sLength = Asc(Mid(iData, 9, 1)) ' find the length of the packet sPackS = i + 1 ' set the position of the packet For j = sPackS To Len(iData) If (j = Len(iData)) And Mid(iData, j, 1) <> "chr(02)" Then sPackE = Len(iData) sAllData = Mid(iData, sPackS, sPackE) sAllData = iData If Len(sAllData) < 3 Then sType = sAllData Else sType = Asc(Mid(sAllData, 2, 1)) sData = Mid(sAllData, 4, (Len(sAllData) - 3)) End If Call Incoming_Data(sType, sData) Exit Sub ElseIf Mid$(iData, sLength + 10, 1) = "chr(02)" Then ' find the end of the packet and process it sPackE = (sLength + 8) sAllData = Mid(iData, sPackS, sPackE) If Len(sAllData) < 3 Then sType = sAllData Else sType = Asc(Mid(sAllData, 2, 1)) sData = Mid(sAllData, 4, (Len(sAllData) - 3)) End If Call Incoming_Data(sType, sData) Exit For End If Next j End If Next i End Sub
this is a data that the server sends to the clientthe above code of the client can handle if the data are less in number for example less than 10 or so...but if i send a lot of data at the same time let's say 100 then 5 or more data are cut off and only 95 are shown in the text box..although in the debug window all the data arrive..the reason for this is..the last data has to run through..Code:chr(02)ô.....Ochr(02)...pannam.... 'roompearls....hello this is a message....chr(02).........but it doesnot..rather runs through the latter part of the code and gives the out put..Code:If (j = Len(iData)) And Mid(iData, j, 1) <> "chr(02)" Then sPackE = Len(iData) sAllData = Mid(iData, sPackS, sPackE) sAllData = iData If Len(sAllData) < 3 Then sType = sAllData Else sType = Asc(Mid(sAllData, 2, 1)) sData = Mid(sAllData, 4, (Len(sAllData) - 3)) End If Call Incoming_Data(sType, sData) Exit Sub
i am uploading my server /client which is quite simple..i hope some body can help me out with this..coz i am stuck with it real bad..![]()
![]()
![]()
![]()
![]()




Reply With Quote