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

x
?
Solved

TCP connections not failing

Posted on 1998-12-15
5
Medium Priority
?
350 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 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

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