From: Alejandro C. <cas...@gm...> - 2008-04-23 12:36:00
|
Hi Lee, when you are reading from a TCP socket, remember that you have a stream of data, there isn't any packets. The concept of packets, it is introduced by the application that uses the socket. In this case, as you send XML data throught the socket you can assume that the end of your "packet" (indeed, the moment when you assume that you have finished reading the socket) could be </rootname> node. Regards Ing. Alejandro Casagrande Advenio Software http://www.advenio.com.ar http://www.voxmaris.com.ar 2008/4/23, Lee Jenkins <le...@da...>: > > Markku Uttula wrote: > > Lee Jenkins wrote: > >> Hi all, which is the best way to receive packets from a tcp server when > there is > >> no explicit terminator to signal the end of the packet? I have to > connect to > >> and get a packet from a server that was written in VB and I think their > using > >> the winsock control that comes with that and do no send a terminate at > the end > >> of the string. > > > > Umm... if there is no explicit terminator, I guess there is an implicit > > one (as otherwise, there'd be no way whatsoever to determine when the > > package is ready to be handled). Of course; if the "package" contains > > first a header of sorts that informs the length of the package, you can > > only read the header part until you know how long the package is, and > > after that read the length of package minus the length already read. > > > > Without knowing more about the datastructure in question, this is of > > course nothing but guessing :) > > > > Thanks Markku, > > It's an XML packet being sent back with a root node that never changes. I > guess > I could look for the </rootname> node, but that didn't seem like the best > way > and I wanted to check if there was a better way before implementing. > > Thanks again, > > -- > Warm Regards, > > Lee > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > synalist-public mailing list > syn...@li... > https://lists.sourceforge.net/lists/listinfo/synalist-public > |