Sunday, May 17, 2009

Terminate a socket without terminating a process:HP-UX

PROBLEM

Terminate a socket without terminating a process

RESOLUTION

Refer to man page on ndd:

#man 1m ndd

ndd -h supported (will display supported ndd parameters)
ndd -h unsupported (will display unsupported ndd parameters)

Here is an example using the tcp_discon parameter:

#ndd -get /dev/tcp tcp_discon number

NOTE: This number is obtained by running the following command:

#ndd -get /dev/tcp tcp_status

The tcp_status will give you a long list of connected sockets. Find the one
that needs to be killed (use netstat -a (if you have the name of the
host, use the -n option if you have the IP of the host you are looking
for) and then compare to ouput of the -get command below to find the
hostname or the ip). Then use the number on the far left of the output
(LEADING ZEROS must be removed from the number) and prepend it with a 0x to
show its hex.

Example of commands:

* #ndd -get /dev/tcp tcp_status
* #ndd -set /dev/tcp tcp_discon 0x010203404

If using the tcp_discon_by_addr variable convert the ip address into the
hexadecimal representation.

#ndd -set /dev/tcp tcp_discon_by_addr [hex number]

Where '[hex number]' is the one that needs to be killed.

:ciao..

No comments:

Post a Comment