How I can see from shell what socket options are set? In particular I'm interesting to know if SO_BROADCAST is set?
相关问题
- How to get the return code of a shell script in lu
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Invoking Mirth Connect CLI with Powershell script
- Error building gcc 4.8.3 from source: libstdc++.so
You can use
lsof(8)
. IfPID
is the process ID andFD
is the file descriptor number of the socket you're interested in, you can do this:To list all IPv4 sockets of a process:
This will print out the socket options with a
SO=
, among other information. Note that if no options are set, you'll get the empty string, so you'll see something likeSO=PQLEN=0
etc. To test forSO_BROADCAST
, just grep for the stringSO_BROADCAST
after theSO=
, e.g.On Linux, you can use the knetstat kernel module to inspect socket options, including
SO_BROADCAST
.