SUMMARY: how to close a socket

From: jbeck (jbeck@dolsun.dol.state.nj.us)
Date: Wed Jul 12 2000 - 08:04:20 CDT


Orig question:
on a few occassions, I've had socket connections which wouldn't close even
after killing the process. Did I kill the process incorrectly--kill -9 $PID
?
i realize this indicates the possible need for an application patch, but is
there a way to close/disconnect this through an os command or utility?
NES & Oracle's listener are among the culprits.

responses:
Several things I would like to comment on:

1. Don't use -9 in kills unless its completely necessary. This
    signal cannot be caught or ignored by processes and
    will cause them to exit without having a chance to
    perform any cleanup.

2. Streaming socket connections (TCP/IP) have a 3 step buildup
    and a 3 step bringdown cycle. See the TCP/IP RFC for details.
    The net result is that sometimes sockets (viewed with netstat)
    will seem to remain up for a while in one of many different
    states (CLOSE_WAIT, etc). This is to allow the completion
    of data transmission and protocol. Sometimes, I have noticed
    that so-called operating systems (NT, win 98) do not have
    a proper implementation of TCP/IP and can cause hangs on
    sockets when talking to system that properly implement
    the protocol (most Unixes).
-------
usually a network application will not allow to reuse a socket pair before
the WAIT3 time is expired. in whish state is your accplicatoin is it in
ESTABLISHED or WAIT State ? if it is in WAIT state it is normal. but it
should definitely close the socket after some times.
-------
sockets will stay in the time wait state for a timeperiod (which can be
tuned) to avoid some other process open the same socket receiving packets
meant for the old process.
check sunsolve on this issue.
---------
Before resorting to the drastic 'kill -9', you might try
a kill -HUP or a kill -TERM... 'Well-written' applications should try to
catch the HUP or theTERM, and clean up accordingly. Not so with the -9
signal, which can be translated as 'terminate with extreme prejudice'
--------
*Never* use a kill -9 unless everything else has failed. This gives
the process no chance whatsoever to clean up after itself, or let
other processes know that it's about to die. Go read the signal (5)
man page and familiarise yourself with the nicest ways to kill
processes.

> i realize this indicates the possible need for an application patch, but
is
> there a way to close/disconnect this through an os command or utility?
> NES & Oracle's listener are among the culprits.

kill -9 is more likely to be the culprit. You may be able to check
if there's something on the other side of the port via lsof (which
you may need to download), in which case, you might be able to kill
off the process which still has it open. I'd guess that it's talking
to something on localhost, which is why it still exists - the process
on the other side of the port doesen't know that it's dead
----------
as always, thanks to all
______________________________________________________
Joe Beck Unix Administrator/Tax Redesign Project
jbeck@dol.state.nj.us
voice: (609)292-5785

-----Original Message-----
From: owner-sun-managers@sunmanagers.ececs.uc.edu
[mailto:owner-sun-managers@sunmanagers.ececs.uc.edu]On Behalf Of Jacques
Rall
Sent: Tuesday, July 04, 2000 5:21 AM
To: Sun Managers
Subject: which process for a socket

Hi SMs,

How can I find out which process is using a specific port?

Here is the output of ´netstat -v|grep 17510´ for this TCP/IP port:

Local/Remote Address Swind Snext Suna Rwind Rnext Rack
Rto Mss State
-------------------- ----- -------- -------- ----- -------- --------
----- ----- ------
treasury3.17510 8760 d5696b3f d5696b3f 0 6c5f8b8f 6c5f8b8f
780 1460 ESTABLISHED

Thanks,
Jacques

S
U BEFORE POSTING please READ the FAQ located at
N ftp://ftp.cs.toronto.edu/pub/jdd/sun-managers/faq
. and the list POLICY statement located at
M ftp://ftp.cs.toronto.edu/pub/jdd/sun-managers/policy
A To submit questions/summaries to this list send your email message to:
N sun-managers@ececs.uc.edu
A To unsubscribe from this list please send an email message to:
G majordomo@sunmanagers.ececs.uc.edu
E and in the BODY type:
R unsubscribe sun-managers
S Or
. unsubscribe sun-managers original@subscription.address
L To view an archive of this list please visit:
I http://www.latech.edu/sunman.html
S
T

S
U BEFORE POSTING please READ the FAQ located at
N ftp://ftp.cs.toronto.edu/pub/jdd/sun-managers/faq
. and the list POLICY statement located at
M ftp://ftp.cs.toronto.edu/pub/jdd/sun-managers/policy
A To submit questions/summaries to this list send your email message to:
N sun-managers@ececs.uc.edu
A To unsubscribe from this list please send an email message to:
G majordomo@sunmanagers.ececs.uc.edu
E and in the BODY type:
R unsubscribe sun-managers
S Or
. unsubscribe sun-managers original@subscription.address
L To view an archive of this list please visit:
I http://www.latech.edu/sunman.html
S
T

S
U BEFORE POSTING please READ the FAQ located at
N ftp://ftp.cs.toronto.edu/pub/jdd/sun-managers/faq
. and the list POLICY statement located at
M ftp://ftp.cs.toronto.edu/pub/jdd/sun-managers/policy
A To submit questions/summaries to this list send your email message to:
N sun-managers@ececs.uc.edu
A To unsubscribe from this list please send an email message to:
G majordomo@sunmanagers.ececs.uc.edu
E and in the BODY type:
R unsubscribe sun-managers
S Or
. unsubscribe sun-managers original@subscription.address
L To view an archive of this list please visit:
I http://www.latech.edu/sunman.html
S
T



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:14:11 CDT