socket
摘要:【socket】socket.socket([family[, type[, proto]]]) The address family should be AF_INET (the default), AF_INET6 or AF_UNIX.The socket type should be SOC...
阅读全文
struct
摘要:【struct】1、五个方法。 2、Struct类。
阅读全文
Format Characters
摘要:【Format Characters】 A format character may be preceded by an integral repeat count. For example, the format string '4h' means exactly the same as '...
阅读全文
Byte Order, Size, and Alignment
摘要:【Byte Order, Size, and Alignment】 By default, C types are represented in the machine’s native format and byte order, and properly aligned by skipping...
阅读全文
socket.gethostname() vs socket.getfqdn()
摘要:【socket.gethostname() vs socket.getfqdn()】 gethostname()把域名转换为IP。
阅读全文
Site-specific configuration
摘要:【Site-specific configuration】 site.py会被自动导入。通过-S选项可阻止此行为。 Importing this module will append site-specific paths to the module search path and add a ...
阅读全文
sys.path
摘要:【sys.path】 A list of strings that specifies the search path for modules. modules的搜索路径。 Initialized from the environment variable PYTHONPATH. 从环境变量...
阅读全文
sys.platform
摘要:【sys.platform】 一个字符串,指明当前是哪个操作系统。常用的操作系统如下: 名字与 uname -s 的输出一致。 对于Linux有以下要点要注意。
阅读全文
HTMLParser
摘要:【HTMLParser】1、一个解析Title的Parser。 2、翻译实体。 3、字符串参考的处理。
阅读全文
urllib2
摘要:【urllib2】1、基本用法 。 2、geturl()方法 3、urllib.urlencode方法。 4、添加post数据 。 5、连接的过程最容易出错。
阅读全文
高级网络操作
摘要:【高级网络操作】1、shutdown()函数使socket变为半开放。 2、close与fork。 3、socket.settimeout()设置超时。4、二进制数据没有可用的惟一字符串标识码。5、转义符解决newline问题。 6、通过socket.setsockopt()来设置发送广播。 ...
阅读全文
Host指令
摘要:【Host指令】 查询IP地址。 1、socket.gethostname() 2、getfqdn() 3、getaddrinfo() 4、getservbyname()查找端口号。 5、getsockname()、getpeername() 6、struc...
阅读全文
Network Servers
摘要:【Network Servers】1、建立服务器分四步。 2、SO_REUSEADDR 选项。 3、getsockopt() 4、常用socket选项。 5、使用man。 6、Ctrl+C异常。 7、accept会阻塞,并不耗费CPU。8、UDP不需listen、accept...
阅读全文
Network Client
摘要:【Network Client】1、socket可以被看成一个标准的文件描述符,程序并不知道它正在把数据与进一个文件、终端或TCP连接。2、通信类型、协议家族。 3、connect 方法。 4、getsockname、getpeername。 5、tcp连接的行为更像是标准的文件,它们保证...
阅读全文
TCP的可靠性
摘要:【TCP的可靠性】 首先,需要知道网络的问题有哪些: 1、Modem有可能改变了数据的几个字节。——损坏。 2、某个路由器或许丢失了一两上信息包。——丢包。 3.1、系统或许收到了顺序错误的信息包。——乱序。 3.2、 个信息包或许收到了两次。——多包。 4、网络电缆...
阅读全文
Introduction
摘要:【Introduction】1、Python程序第一行 #! 用于告诉操作系统去哪里找解释器来执行代码。2、所有要运行的程序必须具有可执行的权限。使用 chmod3、每个机器都有惟一的IP地址,IP地址用于区分机器。4、每个网络应用都有端口,端口用于区分包该发往哪。5、IANA维护已分配的端口号。如...
阅读全文