How can I see from the shell how the socket options are set? Especially I find it interesting to know if SO_BROADCAST is set up?
You can use if the PID
is the process id and < Code> FD is a file descriptor number of the socket of your interest, so you can:
LSOF-A-P PID-D FD-T F / To list all IPv4 sockets of a process:
LSOF-A-P PID - I 4 -T f
this will print the socket option with a SO =
, other go Note the officer that you do not set any options, you will be an empty string, so you'll see something like SO = PQLEN = 0
etc. To test for SO_BROADCAST
, just type SO =
after the string SO_BROADCAST
for grep, for example
If lsof -a -p PID -d FD-T f | Grep -q 'SO = [^ =] * SO_BROADCAST'; So #Socket is SO_BROADCAST and #, it is not
No comments:
Post a Comment