Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Apr : service running out of socket resources

www.cryer.info
Managed Newsgroup Archive

service running out of socket resources

Subject:service running out of socket resources
Posted by:"Brad White" (bwhite at inebraska.com)
Date:Fri, 22 Apr 2005 14:19:25

I have a service that communicates over sockets.  If a connection fails
it re-tries to connect.  After ~4000 tries, it runs out of resources.
Once it runs out, all processes using sockets on the machine are affected.
No one can connect.
Restarting the app releases the resources which fixes the problem.

The error message is:
Windows socket error: An operation on a socket could not be performed
because the system lacked sufficient buffer space or because a queue was
full (10055), on API 'connect'

Destroying the socket and recreating it every time has no effect.

This resource leak occurs only when it fails to connect.  Successful
connections
do not appear to be leaking resources.

Here is the code snippet:
FormCreate
begin
  commSocket:=TClientSocket.Create(nil);
end;

Connect
begin
  commSocket.Close;
  commSocket.Address := 'NONEXISTENTSERVER';
  commSocket.Port := 6999;

  try
    commSocket.Open;
  except
    memLog.Lines.Add('CommSocket.Open Exception');    // Raises an exception
once it runs out of resources.
    raise;
  end;
end;

The complete app is in b.p.attach.

Can anyone reproduce?

Windows XP Pro, sp2
IE 6.0.2900

Same results on Win 2003 Server.
--
Brad.

Replies:

www.cryer.info
Managed Newsgroup Archive