Solved

TCP connections not failing

Posted on 1998-12-15
5
329 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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.

830 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