Solved

TCP connections not failing

Posted on 1998-12-15
5
345 Views
Last Modified: 2013-12-06
I have a TCP server process running on a HP-UX box accepting connection from a quenix client. Sometimes when the quenix box goes down, the server waiting on a connected blocked 'recv' socket, does not come out, meanwhile client gets re-started and gets re-connected to the server [ Server has backlog of upto 5 ]. Is there a setting or parameter which could fix this problem? Also, the connection between the two is thru a T1 line [If that makes any difference at all ]
0
Comment
Question by:mmanju
[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
  • 2
  • 2
5 Comments
 

Author Comment

by:mmanju
ID: 2008429
Edited text of question
0
 
LVL 2

Accepted Solution

by:
rdelfino earned 100 total points
ID: 2008430

You have got to set the SO_KEEPALIVE option on the  socket
right after you accept() the connection. Doing so, the OS will
probe if the client is still alive and the blocked recv() will return
with an error.  

The problem is that the kernel waits from 30 seconds up to 12 hours for response on the socket. So, if the client is restarted in
a smaller time than the time the kernel finds out the socket is
no longer alive, you may have another pending connection from the client that restarted while you are blocked on recv().

It is possible to config the waiting time in a config file that is read at boot time (Sorry, but I don't know which file is this in HP-UX).

Also, try spanning a thread/process to treat new connections.
This way you can accept() new connections while the child
processes/threads are blocked on recv().

The piece of code below show setting the SO_KEEPALIVE
option and spanning a new proccess to treat the new
connection.

/* . . . . . .  */

int aux;
int s;
int listenSocket;
char buff[BUFFSIZE];

/* . . . . */

for(;;)
{
  s = accept(listenSocket, NULL, NULL);

  if (s < 0)
  {
    continue;
  }
  aux = 1;
  setsockopt(s, SOL_SOCKET,  SO_KEEPALIVE, &aux, \
  sizeof(int));
 

  if (!fork())
  {
    /* child proccess */
    close(listenSocket);
    /* . . . . */  

    recv(s, buff, BUFFSIZE);
   
    /* . . . */
  }
  close(s);
}

I hope it helps

Reginaldo

0
 

Author Comment

by:mmanju
ID: 2008431
Would it be possible to tell me the name of the file on an AIX box or any UNIX box for that matter, which can give me a hint for looking into HP-UX files?
0
 

Expert Comment

by:rajeevm
ID: 2008432
Hello
CAN YOU PLEASE TRY CHANGING THE TCP KEEP ALIVE INTERVAL BY USING
NO COMMAND .
REGARDS,
Rajeev Mishra
0
 

Expert Comment

by:rajeevm
ID: 2008433
while adding the previous comment the link went down so i was not knowing what got added , the above suggestion is for AIX box
only ,i am not familiar with HP
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

623 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