Article View: borland.public.cppbuilder.internet.socket
Article #2591Re: TIdTCPClient lack of Knowledge
From: Remy Lebeau (TeamB)
Date: Mon, 13 Mar 2006 20:26
Date: Mon, 13 Mar 2006 20:26
53 lines
3090 bytes
3090 bytes
"Bilgi Sakarya" <b.sakarya@riskreturn.ch> wrote in message news:4415a914$1@newsgroups.borland.com... > But in BCB 2006 I get absolutely now events triggered!! That is because there are not supposed to be any events triggered. Indy is not an event-based library. Its operations are synchronous, not asynchronous. Simply call ReadBuffer() (or other appropriate reading method) immediately after calling WriteBuffer(). > Strange enough, when adding following line of code after the > WriteBuffer Method a get the OnReceive Event triggered!!!! As well it should be, because that is how Indy is designed to work. You called a reading method on the connection, so data is read from the socket at that point in time, and then passed to the Intercept that you have assigned to perform additional processing on the received data. If you think that using a TIdConnectionIntercept will give you asynchronous events, then that is not how Intercepts are to be used. > AnsiString str_line = tcp_client->ReadLn( "\r\n", 1000, > sizeof(STRUCT_STRING_RESULT) ); Since you are reading a fixed-length structure, I suggest that you use ReadBuffer() instead of ReadLn(). > My problem is, that I'm passing quite large data, that means the size > varies between 1000 and 200000 bytes depending on the request. > That means, that I'm receiving more than one packet. Indy handles multiple packets internally. All you have to do is tell Indy how much to read total, and it keeps reading until that amount is received in full. Which means that you have to know ahead of time how much data is going to be sent - or - know how the data is begin to be terminated. > What is also strange, that Indy 9 on BCB6 works totally different. No, it does not. Indy 9 is the same in both BCB and BDS. > There the OnWorkBegin, OnWork and OnWorkEnd are triggered. Only in the context of other reading operation. Again, Indy is not an asynchronous library. You should not be relyiung on events to handle the connections. > But I'm not getting the amount of Bytes I'm expecting. That is because you are not using Indy properly to begin with. Gambit
Technical Details
Message-ID:
<4415d536@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4415a914$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,422c519991c90239 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: <4415a914$1@newsgroups.borland.com> Subject: Re: TIdTCPClient lack of Knowledge Date: Mon, 13 Mar 2006 12:26:45 -0800 Lines: 55 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: <4415d536@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1142281526 68.69.17.41 (13 Mar 2006 12:25:26 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail