Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Apr : Socket connect, write, read, disconnect causes Socket InUse
| Subject: | Socket connect, write, read, disconnect causes Socket InUse |
| Posted by: | "Cronje Fourie" (cfour..@e-intelligence.com) |
| Date: | Tue, 17 Apr 2007 10:33:41 |
Hi all...
I've got a TIDTCPServer running that processes data requests. In order
to test performance I've written a small app that creates multiple
client threads to connect to my server.
The client application uses TIdTCPClient objects within each thread to
connect to the server.
The code looks like this.
procedure TClientThread.Execute()
var
res: string;
begin
client := TIdTCPClient.Create;
client.port := portval;
client.host := hostval;
while not terminated do
begin
client.Connect(500);
client.ReadTimeOut := 25000;
client.writeln(request + cmdTerm);
res := client.waitfor(cmdTerm);
client.disconnect;
end;
client.Free;
end;
If I create 1 or 2 threads the system works well. But if I create 10
threads the system runs for a number of iterations and then crashes with
a "Socket Inuse" error message.
Any thoughts?