Hi,
I have a program client using a TClientSocket to connect to a program server using TServerSocket.
In the program Server I am working with threading blocking.
When a client connect to the server program, the server program creates a new thread connection.
The thread continues to exist while the method TServerClientThread.ClientExecute is not over.
for example:
I put a loop in the thread so as to hold the thread to future use, but I wouldn't like to have a proccess running infinitely. I would like to use the command suspend() but I don't know how to resume the thread when the client program is in need of having communication with the server program through the same thread which was suspended after receiveing the client's message.
Somebody could give me hints!
Thanks in advance!
I have a program client using a TClientSocket to connect to a program server using TServerSocket.
In the program Server I am working with threading blocking.
When a client connect to the server program, the server program creates a new thread connection.
The thread continues to exist while the method TServerClientThread.ClientExecute is not over.
for example:
Code:
Procedure TOperatorServerThread.ClientExecute;
begin
SocketStream := TWinSocketStream.Create(ClientSocket, 5000);
try
WHILE ClientSocket.Connected And Not Terminated Do
begin
FillChar(Data, SizeOf(Data), 0);
If SocketStream.Read(Data, SizeOf(Data)) <> 0 Then
begin
RecText := Data;
ClientSocket.SendText(RecText+', Ok!');
end;
Suspend();
end;
Finally
SocketStream.Free;
End;
end;
I put a loop in the thread so as to hold the thread to future use, but I wouldn't like to have a proccess running infinitely. I would like to use the command suspend() but I don't know how to resume the thread when the client program is in need of having communication with the server program through the same thread which was suspended after receiveing the client's message.
Somebody could give me hints!
Thanks in advance!