显示电脑所安装python所支持的socket选项列表

setsockopt()和getsockopt()

用如下程序

#!/usr/bin/env python
#for use:
#author: jpuyy date  jpuyy.com stubusy@gmail.com
#modified by xx at date
#version:
#history:
#relate on:

import socket
solist = [x for x in dir(socket) if x.startswith('SO_')]
solist.sort()
for x in solist:
    print x

执行后显示

SO_ACCEPTCONN
SO_BROADCAST
SO_DEBUG
SO_DONTROUTE
SO_ERROR
SO_KEEPALIVE
SO_LINGER
SO_OOBINLINE
SO_RCVBUF
SO_RCVLOWAT
SO_RCVTIMEO
SO_REUSEADDR
SO_SNDBUF
SO_SNDLOWAT
SO_SNDTIMEO
SO_TYPE

setsockopt()用法

socket.setsockopt(level, optname, value)

getsockopt()用法

socket.getsockopt(level, optname[, buflen])

参见

http://docs.python.org/library/socket.html

:)EOT

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.