Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 25th, 2005, 4:13 PM   #1
Eriedor
Newbie
 
Join Date: Feb 2005
Posts: 1
Rep Power: 0 Eriedor is on a distinguished road
Indy Components

Hi im having an annoying problem.

Im making a client-server app using indy componenets idtcpclient and idtcpserver naturally.
I should say im a fairly new user to delphi and very new to using indy components so please bare with me if i act a noob.
After browsing throught the indy demos i started my app.

To check for new data on the socket i use a timer that reads the socket every second like so, i saw the technique used in a demo:


procedure TFrmJoin.TimerDatainTimer(Sender: TObject);
Var Inputdata: string;
begin
if not idtcpclient.Connected then
exit;

Inputdata := idtcpclient.ReadLn('',5);
If inputdata <> '' then
begin
If Inputdata[1] = 'C' then
lstchat.Items.Add(HostPlayer+': '+Inputdata);
if Inputdata[1] = 'P' then
begin
frmjoin.Caption := 'Playing Game with - '+Inputdata;
Hostplayer := Inputdata;
end;
end
end;

After it reads whats on the socket it then freezes. However the demo which uses exactly the same technique doesnt freeze. Just wondering if someone could help me out The if statements just determine what kind of data the string is, P for playername C for chat.

p.s. demo code:

procedure TForm1.Timer1Timer(Sender: TObject);
var
Com,
Msg : String;
begin
if not IdTcpClient1.Connected then
exit;

Msg := IdTCPClient1.ReadLn('', 5);

if Msg <> '' then
if Msg[1] <> '@' then
begin
{ Not a system command }
memLines.Lines.Add(Msg);
end
else
begin
{ System command }
Com := UpperCase(Trim(Copy(Msg, 2, Pos(':', Msg) -2)));
Msg := UpperCase(Trim(Copy(Msg, Pos(':', Msg) +1, Length(Msg))));
if Com = 'CLIENTS' then
lbClients.Items.CommaText := Msg;
end;

end;
Eriedor is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC