|
-
Aug 9th, 2005, 02:41 PM
#1
Winsock...
VB Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim incommingData As String
Winsock1.GetData incommingData
Text1 = Replace(incommingData, "\", vbCrLf)
End Sub
all the data is not coming back.. it seems to get cut off..at 1399
I know there is more because the last line I see stops mid word...
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Aug 9th, 2005, 03:48 PM
#2
Re: Winsock...
Do you get another data arrival event with the rest of the data?
-
Aug 9th, 2005, 03:49 PM
#3
Re: Winsock...
nope.. I tried making it text1 = text1 & etc...
I put a msgbox in there.. nothing!???
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Aug 9th, 2005, 03:52 PM
#4
Re: Winsock...
here is all the code: (IP Removed )
im trying to query a game server (BF2) and the results arent complete 
VB Code:
Private Sub Command1_Click()
Text1 = ""
Winsock1.SendData Text2
End Sub
Private Sub Command2_Click()
frmMain.Show
End Sub
Private Sub Form_Load()
Winsock1.Connect "xx.xx.xxx.xx", "29900"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command1_Click
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim incommingData As String
Winsock1.GetData incommingData, vbString, bytesTotal
Text1 = Text1 & incommingData
Me.Caption = Len(incommingData) & " : " & bytesTotal
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Aug 10th, 2005, 07:18 AM
#5
Re: Winsock...
anyone?
do I need to loop somehow in the data arrival to get all of it?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Aug 10th, 2005, 11:28 AM
#6
Re: Winsock...
It does this to me too, i have a boolean that is set to true after the first time data arrival come and then the second time it executes my code. However you should be getting a 2nd dataarrival
-
Aug 10th, 2005, 11:40 AM
#7
Fanatic Member
Re: Winsock...
I wrote a small sender program and the problem I ran into was when you sent the data to the listener program the send was not instantaneous so I had to add a DoEvents to get it to work.
This might also be the problem when listening for information...Not sure but might be a thought.
VB Code:
Winsock.SendData (Data)
DoEvents
-
Aug 10th, 2005, 12:10 PM
#8
Re: Winsock...
well, when the player list is small.. I get all the data back.. but it seems to cut off after 1399 bytes...
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Aug 10th, 2005, 02:03 PM
#9
Frenzied Member
Re: Winsock...
I don't see anything in your code that would be causing the problem. Are you certain that there isn't a problem with the server? Do you know that it sends everything when the player list is large?
FWIW, here is the Data_Arrival code from one of my apps that receives large records in chunks and appends them until the entire record is received. Other than being a bit more involved, it handles the chunks in the same manner as your code.
Code:
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
' determine the data type and process it
' get the buffer contents
ReDim gbIOBuff(bytesTotal)
tcpClient.GetData gbIOBuff, vbArray + vbByte, bytesTotal
If copyPtr = 0 Then ' we are at the beginning of a new reply
' save size & type of reply
CopyMemory recLen, gbIOBuff(0), 4 ' get the record length
recLen = ntohl(recLen) ' convert to little-endian
Debug.Print "Record size = " & recLen
CopyMemory codeCheck, gbIOBuff(52), 2 ' get the reply type
codeCheck = ntohs(codeCheck) ' convert to little-endian
ReDim gbReplyBuff(bytesTotal) ' clear old data record & start new one
Else
ReDim Preserve gbReplyBuff(copyPtr + bytesTotal) ' retain data & bump the size
End If
Debug.Print "Bytes received = " & bytesTotal
' copy the received data to the work buffer at location referenced by copyptr
CopyMemory gbReplyBuff(copyPtr), gbIOBuff(0), bytesTotal
If UBound(gbReplyBuff) = recLen Then
' we got the entire file
If codeCheck = glLocRequest Then
Process_Locations (recLen) ' called 1 time only at Form_Load
ElseIf codeCheck = glJobRequest Then
Process_JobStats (recLen) ' called for each chart request
Else
Beep
If codeCheck = glError Then
CopyMemory ErrIPC, gbIOBuff(0), bytesTotal
sbStatus.Panels(2).Text = "Error: " & codeCheck & ", " & _
Left$(ErrIPC.RepErrMsg, ErrIPC.RepMsgLen)
Else
sbStatus.Panels(2).Text = "Error: " & codeCheck & ", No data returned"
End If
intTics = 0 ' reset display timer
End If
copyPtr = 0 ' reset the flag\pointer
Else
' save the current record length\next copy location
copyPtr = UBound(gbReplyBuff)
End If
End Sub
I added the 2 Debug.Print lines that you see above to demonstrate the chunks arriving for 2 different records. Here is their output:
Record size = 380
Bytes received = 380
Record size = 20378
Bytes received = 3780
Bytes received = 3780
Bytes received = 3780
Bytes received = 3780
Bytes received = 3780
Bytes received = 1478
-
Aug 20th, 2005, 05:22 PM
#10
Lively Member
Re: Winsock...
Make sure you aren't receiving byte 0 (or is it 255?) "EOF" chars that cause anything else sent to the textbox to not be shown!
-
Dec 19th, 2005, 03:39 PM
#11
Re: Winsock...
Static, a question, why are you using TCP? They send UDP packets
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
|