Article View: borland.public.cppbuilder.internet.socket
Article #356Re: replacing ReadBuffer in Indy10
From: Colin B Maharaj
Date: Sun, 23 Mar 2008 00:19
Date: Sun, 23 Mar 2008 00:19
50 lines
2272 bytes
2272 bytes
What you can also probably do, as I did using indy 9 (sorry I do not use indy 10 yet) is get the socket handle similar to this... int isocket = AThread->Connection->Socket->Binding->Handle; and do this.... unsigned char * s = new unsigned char [8200]; int r = recv(isocket, s, 8192, 0); if r == 0 then do this..... AThread->Connection->Disconnect(); and terminate else if r == -1 this is an error so go look up WSAGetLastError(); and if r > 0 then you got data in s and r is the length! Dennis Cote wrote: > I am porting an application from Indy 9 to Indy 10. > > In Indy 9 I had code to read data into a dynamically allocated char > buffer using ReadBuffer. > > char* Buffer; > int Length; > > ... > ReadBuffer(Buffer, Length); > ... > > I have found that I need to do the following instead in Indy 10. > > char* Buffer; > int Length; > > ... > TIdBytes byteBuf; > byteBuf.Length = Length; > IOHandler->ReadBytes(byteBuf, Length); > BytesToRaw(byteBuf, Buffer, Length); > ... > > My question is, is there a way to get Indy 10 to read directly into the > existing char buffer? I would like to avoid the extra allocations and > the buffer copy if possible. > > TIA > Dennis Cote
Technical Details
Message-ID:
<47e5a1fb$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<47e28ff7$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,b74f9f50d42f1dea X-Google-Attributes: gid11508e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Sat, 22 Mar 2008 20:19:09 -0400 From: Colin B Maharaj <noreply@myhost.com> User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: replacing ReadBuffer in Indy10 References: <47e28ff7$1@newsgroups.borland.com> In-Reply-To: <47e28ff7$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 080322-0, 03/22/2008), Outbound message X-Antivirus-Status: Clean NNTP-Posting-Host: 190.58.55.89 Message-ID: <47e5a1fb$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1206231547 190.58.55.89 (22 Mar 2008 17:19:07 -0700) Lines: 50 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail