cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Question about port hang

 
SOLVED
Go to solution
Jason Berendsen
Regular Advisor

Question about port hang

My DBA has a program written in Perl that allows a machine to connect to port 9991. This program sits in a listen state until it gets a request. At the time someone telnets to this port a connection is established with a new forked process. When closing this connection the forked process is closed, you can't see it anymore with a ps -ef. But if you do a netstat -an |grep 9991 you can still see the connection in close_wait. The odd thing about this is if you were to do multiple telnets to 9991 and close each one they all close properly except for the first process that is closed. This one stays in a close_wait state. Any idea what could cause this???

Thanks,

Jason
2 REPLIES 2
Dwyane Everts_1
Honored Contributor
Solution

Re: Question about port hang

Jason,

There is a ton of useless....um, I mean, useful information in this thread. Perhaps it will help you.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=671167

Dwyane :)
A. Clay Stephenson
Acclaimed Contributor

Re: Question about port hang

Tell your DBA to use shutdown() rather than close() on his sockets. I'll quote the perlfunc manpage under shutdown:

Quote -----------
shutdown(SOCKET,0); # stopped reading data
shutdown(SOCKET,1); # stopped writing data
shutdown(SOCKET,2); # stopping using this socket

This is useful with sockets when you want to tell the other side you're done writing but not done reading, or vice versa. It's also a more insistant form of close because it also disables the file descriptors in any forked copies in other processes.
------------- Endquote

The good news is that shudown() is also available as an IO::Socket method as well so
that $mysocket->shutdown(2); will work as well.
If it ain't broke, I can fix that.