| Dart Home | PowerTCP Server for ActiveX | Custom Development | Reply | PowerTCP Server for ActiveX Topics | Forums |
| Author | Forum: PowerTCP Server for ActiveX Topic: TCP Messages arriving in two pieces |
| User847 Posts: 5 Member Since: 03/15/01 |
posted November 23, 2005 3:28 PM I'm having an issue with an application that is using the Server control to communicate via TCP/IP with another vendors product. The problem is that the messages from the Vendors product are arriving in pieces and I can't figure out a good way to get them back together. The format of the message is: Header,Record,Record with the Header and record fields looking like: Field1|Field2|...FieldN As an example, the Login message I receive from the application should be: RTA|LOGIN|1|11222005165629|1,Password, RTA|LOGIN|1|11222005165629|1 is the Header and Password is the "record" for this message. When the Receive event fires and I use the Receive method to retrieve the data I get just the Header. The next time the Receive event fires I get the record portion and sometimes the Header from the next message. The header and records never arrive together. The messages don't have a terminating character to search for and the messages are all variable in length. I guess my question is can I wait a little after the Receive event fires for the entire message to arrive? I've tried a loop with DoEvents embedded and that didn't seem to do it. It's easy to split messages up if more then one arrives. Not so easy to know how to piece them back together. I really don't want to use a timer. Could the Timeout property effect this at all? How about receive buffer size? (The headers will always be a minimum of 27 characters in length.) |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted November 27, 2005 1:21 PM This is a very common issue with beginners to TCP programming. TCP is a stream oriented protocol. Protocol's that derive from it (like the 'Vendors Product you mention) need to have defined ways to detect the end of data. I'm guessing with that records are delimited by lines (crlf) in your protocol, so you should write your client to always receive up to a crlf. |
| Reply | PowerTCP Server for ActiveX Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|