![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 1
Rep Power: 0
![]() |
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; |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|