Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TCP Connection Limit ?

Posted on 1998-10-08
4
Medium Priority
?
247 Views
Last Modified: 2013-12-23
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!
0
Comment
Question by:AndrewR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Author Comment

by:AndrewR
ID: 1582415
Edited text of question
0
 

Author Comment

by:AndrewR
ID: 1582416
Edited text of question
0
 

Accepted Solution

by:
ydsh earned 800 total points
ID: 1582417
Try to insert these codes into your loop:

struct linger  socketLinger;  
.
        socketLinger.l_onoff = 1;
        socketLinger.l_linger = 0;
        if(setsockopt(fSocket,SOL_SOCKET,SO_LINGER,
                           &socketLinger,sizeof(struct linger)) == -1){
                perror("set sock opt error");
                return(-1);
        }                      
.

Then it should work.  If, it still do not work, then the problem must lay on your NT server. :)
For in my unix-unix network, communication, no problem occured!                                              
0
 

Author Comment

by:AndrewR
ID: 1582418
Thanks
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is in regards to the Cisco QSFP-4SFP10G-CU1M cables, which are designed to uplink/downlink 40GB ports to 10GB SFP ports. I recently experienced this and found very little configuration documentation on how these are supposed to be confi…
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question