bish wakim
asked on
How Indy IdTcpServer can transfer data of several lines to a Client?
I Made a simple "server client" program with IdTcpServer and IdTcpClient components created with Delphi rad seattled 10.
Is there an efficient way to make the server send a data to the client at the moment when this client is connected.
the data should contain several lines when each line Describes each client already connected to the server ( Id, Age name ...etc)
Thanks in Advance!
Is there an efficient way to make the server send a data to the client at the moment when this client is connected.
the data should contain several lines when each line Describes each client already connected to the server ( Id, Age name ...etc)
Thanks in Advance!
ASKER
Thank you. Iam going to test your solution very soon and come back to you.
Happy New year...
Happy New year...
ASKER
As a matter of fact in my Indy version "AThread: TIdPeerThread" is replaced by "AContext: TIdContext "...
Here as my actual problem:
1. The Server (MyServer:TdTcpServer) receives a message from client(MyClient:IdTcpClien t) then returns another message to the same
client through the following event:
procedure TFServer.MyserverExecute(A Context: TIdContext);
var msgFromClient:string,msgTo Client;
begin
msgFromClient := AContext.Connection.IOHand ler.ReadLn ;
......
AContext.Connection.IOHand ler.WriteL n(msgToCli ent));
......
end;
2. the messageToClient is captured by MyClient through TthreadComponent wich was activated inside the client application. In the client
application TIdTCpClient and TthreadComponent work together...
procedure ClientFormPage.IdThreadCom ponentRun( Sender: TIdThreadComponent)
var msgFromServer:string;
begin
msgFromServer := MyClient1.IOHandler.ReadLn ();
DoSomeThing(msgFromServer) ;
end;
3. the DoSomeThing((msgFromServer ) causes sometimes the Program to hang!!!!!
Please how can I solve this problem????
Here as my actual problem:
1. The Server (MyServer:TdTcpServer) receives a message from client(MyClient:IdTcpClien
client through the following event:
procedure TFServer.MyserverExecute(A
var msgFromClient:string,msgTo
begin
msgFromClient := AContext.Connection.IOHand
......
AContext.Connection.IOHand
......
end;
2. the messageToClient is captured by MyClient through TthreadComponent wich was activated inside the client application. In the client
application TIdTCpClient and TthreadComponent work together...
procedure ClientFormPage.IdThreadCom
var msgFromServer:string;
begin
msgFromServer := MyClient1.IOHandler.ReadLn
DoSomeThing(msgFromServer)
end;
3. the DoSomeThing((msgFromServer
Please how can I solve this problem????
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can you give a little code showing me how can I create a thread with Delphi and perform an action with it?
The DoSomthing that caused the hang was simply when I tried to open a TabControl page wich contains indeed a lot of graphics immediatley after I received an message from the server..
I manged to get red of this problem by going around ,However I don't think it is a good idea to avoid ugly situations without understanding what is really happening.
Thanks in advance
The DoSomthing that caused the hang was simply when I tried to open a TabControl page wich contains indeed a lot of graphics immediatley after I received an message from the server..
I manged to get red of this problem by going around ,However I don't think it is a good idea to avoid ugly situations without understanding what is really happening.
Thanks in advance
ASKER
Thank you Sinisa...
Open in new window
.. note - procedure call custom Broadcast message proc upon client connection wich iterate through
all active client connections and send some message:
Open in new window