TCP End of Transmission /*EOT*/

ZeroEffect

Junior Contributor
Joined
Oct 24, 2004
Messages
204
Location
Detroit, MI
I am converting a program over from UDP to TCP and all is good data is being sent an received. but I have a small problem. the string that gets sent over the tcp connection sometimes is broken up and looks like this.

Visual Basic:
TCP Connection Request
--- 09/07/2005 23:46:53.719

127.0.0.1 : 2402 TCP Connected ID = 1
--- 09/07/2005 23:46:53.719
Status Code: 0 OK

127.0.0.1 : 2402 TCP Data In Length 1 bytes : MD5 = 5DBC98DCC983A70728BD082D1A47546E
--- 09/07/2005 23:46:53.789
0000   53                                                   S


127.0.0.1 : 2402 TCP Data In Length 1 bytes : MD5 = 0D61F8370CAD1D412F80B84D143E1257
--- 09/07/2005 23:46:53.829
0000   43                                                   C


127.0.0.1 : 2402 TCP Data In Length 1 bytes : MD5 = D20CAEC3B48A1EEF164CB4CA81BA2587
--- 09/07/2005 23:46:53.869
0000   4C                                                   L


127.0.0.1 : 2402 TCP Data In Length 17 bytes : MD5 = 02D4BD80CD085B63F916EC89406422C9
--- 09/07/2005 23:46:53.939
0000   2D 50 4C 41 59 5F 50 42 4B 31 2F 2A 45 4F 54 2A      -PLAY_PBK1/*EOT*
0010   2F                                                   /


127.0.0.1 : 2402 TCP Disconnected ID = 1
--- 09/07/2005 23:46:58.776
Status Code: 25856 [25856] (no description available)

What I want is "SCL-PLAY_PBK1/*EOT*" I had built an if statement to build the string but sometimes it worked other times it didn't. the statment looked like this.

Visual Basic:
If recData.endswith(/*EOT*/ ) then
     tempData = tempData + recData
     ProcessData(tempData)
     tempData = ""
Else
     tempData = recData + tempData
End If

This is in the sub where that data is received.

I know there is a way to do this but I am having a brain cramp.

Thanks for any input you may have.

ZeroEffect
 
FWIW, when I do this I append the data received into a StringBuilder. That way you don't create as many objects, if you're worried about that. The messages I received have a start of text and end of text markers, so I look to see if both are there and extract the stuff in between them.

In your code, I'm not sure why you append the received data if it contains your marker, but pre-pend if it doesn't - but I don't know if that's a problem for you.

Mike
 
Back
Top