Link to home
Start Free TrialLog in
Avatar of AndrewR
AndrewR

asked on

TCP Connection Limit ?

I have a UNIX program that loops while trying to make a socket connection. If the connect fails enough I run out of available TCP Connections. Here is a code fragment;
...
do {
  connected_I = -1;

    /*** OPEN SOCKET TO NT SERVER ***/
    fSocket = socket(AF_INET,SOCK_STREAM,0);
    if (fSocket == -1)
    {
      connected_I = 0;
    }

    /*** CONNECT TO SOCKET  ***/
    sin.sin_family = AF_INET;
    sin.sin_addr.s_addr = GetAddr(ip_addr);
    sin.sin_port = htons((u_short)(13011));

    if (connect(fSocket,
                (struct sockaddr FAR *) &sin,
                sizeof(sin))==-1)
    {
     connected_I = 0;
    }

    if (!connected_I)
    {
      shutdown(fSocket,2);
      close(fSocket);
      sleep(2);
    }

} while(!connected_I);
...
Can anyone see anything wrong with this?
Is there a table of some sort in UNIX that gets filled up and only released when my process terminates?
Any help anyone can offer would be great!
Avatar of AndrewR
AndrewR

ASKER

Edited text of question
Avatar of AndrewR

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of ydsh
ydsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AndrewR

ASKER

Thanks