English 中文(简体)
显示选项
原标题:Display socket options
  • 时间:2009-12-01 05:11:05
  •  标签:
  • linux
  • shell

How I can see from shell what socket options are set? In particular I m interesting to know if SO_BROADCAST is set?

最佳回答

您可使用http://linux.die.net/man/8/lsof”rel=“noretinger”>lsof(8)。 程序设计和编码 FD是你重新感兴趣的档案编号,你可以这样做:

lsof -a -p PID -d FD -T f

4. 列出所有IPv4的工序:

lsof -a -p PID -i 4 -T f

除其他信息外,还将用SO=印成单>。 请注意,如果没有办法,你就坐着空洞,因此,请看SO=PQLEN=0等东西。 测试SO_BROADCAST,在后,如:

if lsof -a -p PID -d FD -T f | grep -q  SO=[^=]*SO_BROADCAST ; then
    # socket has SO_BROADCAST
else
    # it doesn t
fi
问题回答

今天我有同样的问题;不幸的是,在我的系统中,<代码>-T 选择。 不接受<代码>f的旗帜,我也不想建立<代码>knetstat kernel模块。

简言之,我能读到<条码>。 该申请在编订时,如:

strace -e trace=setsockopt -f -o /tmp/log ./program arg1 arg2

http://code>/program arg1 arg2, 写上/tmp/log的痕迹。 我们只追踪<代码>setsockopt()系统电话,该系统用于确定备案选择。 选项-fstrace也追踪了追踪方案创建的任何儿童进程。

如果您为uck,/tmp/log将包含如下内容:

18806 setsockopt(60, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0

这表明,程序<代码>18806 :setsockopt(> on FD 60 to setSO_KEEPALIVE to 1(使其得以通过),而该系统采用返回代码<0>

还可考虑现行程序:

strace -e trace=setsockopt -f -o /tmp/log -p PID

您可使用<条码>CTRL-C,并略去<条码>-o 选项及其将痕迹发送至<条码>stder的论点。





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签