Article View: borland.public.cppbuilder.internet.socket
Article #5095Re: Reading Binary Data
From: Remy Lebeau (TeamB)
Date: Fri, 15 Oct 2004 21:10
Date: Fri, 15 Oct 2004 21:10
28 lines
1968 bytes
1968 bytes
"Paul Machiaverna" <paul.machiaverna@i-stat.com> wrote in message news:4170363b$1@newsgroups.borland.com... > I'm using INDY 9 in a server application and would like to know the preferred method of reading binary data from a client. That depends on how the client is sending the data exactly, but typically you should use the ReadBuffer() or ReadStream() method. > I've been using this code (in the OnExecute method): I would not recommend that approach. A better approach would be for the client to send the size of the data before the data itself. Then your server can read the size first and know how many remaining bytes to read afterwards. Then you don't need to use Readable() and CurrentReadBuffer() at all. > ProcessData feeds each byte through a state machine to determine the end of data marker. That is also not a good approach. If the client sends the data size, then you will know exactly how many bytes belong to each record. Then you don't need end markers at all, although you could still use them if you want to validate the data integrity, at least Gambit
Technical Details
Message-ID:
<41703c92$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4170363b$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,86d2a32b454a1312 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <4170363b$1@newsgroups.borland.com> Subject: Re: Reading Binary Data Date: Fri, 15 Oct 2004 14:10:00 -0700 Lines: 30 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <41703c92$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1097874578 68.69.17.41 (15 Oct 2004 14:09:38 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail