I want it to be read as data comes in (onevent) not have to wait after sending something each time
Tom
Main Topics
Browse All TopicsHey, Im having a problem where I connect to 127.0.0.1 on port 666 using the function in button1 then onconnect i get a message saying it connects just fine. Now button2 sends the character 'F' and its supposed to get a bunch of data back. Well the TcpClient1Recieve function never gets called... why?
if i do
telnet 127.0.0.1 666
F
GOT:F
it works just fine.
Now what am i doing wrong? and please dont tell me to work around it by using indy or whatever else.
Tom
procedure TForm1.Button1Click(Sender
begin
TcpClient1.Connect
end;
procedure TForm1.TcpClient1Receive(S
var DataLen: Integer);
begin
showmessage('GOTDATABACK')
end;
procedure TForm1.TcpClient1Connect(S
begin
ShowMessage('Connected');
end;
procedure TForm1.Button2Click(Sender
begin
TcpClient1.Sendln('F');
end;
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The way indy works is that a client invokes an action on a server, because of this the client has no direct way of activating when it receives data. You can get round this by using a timer
set up a timer, say 500ms and then on the timer do
this if for INDY 9
var
lMsg: string;
begin
Timer1.Enabled:=false;
lMsg:=idTCPClient1.ReadLn;
if lMsg<>'' then
begin
{process your message here}
end;
Timer1.Enabled:=true;
end;
for Indy 10 which I haven't got installed I think you need
var
lMsg: string;
begin
Timer1.Enabled:=false;
lMsg:=idTCPClient1.IOHandl
if lMsg<>'' then
begin
{process your message here}
end;
Timer1.Enabled:=true;
end;
regards
try this:
procedure TForm1.Timer1Timer(Sender:
begin
If idtcpclient1.Connected then Begin
IdTCPClient1.CheckForGrace
If not IdTCPClient1.IOHandler.Inp
End;
end;
NB: It uses a timer event to check if there is data to read, if there is, it reads it...
Mainiacfreakus
Business Accounts
Answer for Membership
by: pcsentinelPosted on 2006-04-06 at 05:17:36ID: 16390942
var ;
lResult: string;
begin
TcpClient1.Sendln('F');
lResult:=TcpClient1.ReadLn
end;