Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Threads connection

Status
Not open for further replies.

edgarasm

Programmer
Oct 29, 2002
26
BR
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:

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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top