Think before you speak, read before you think.

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

setsockopt()和getsockopt()

用如下程序

#!/usr/bin/env python
#for use:
#author: jpuyy date  jpuyy.com [email protected]
#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


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *