socket 常见方法:
补充说明:what is file descriptor? 文件描述符是什么?
参考(http://stackoverflow.com/questions/8191905/whats-is-difference-between-file-descriptor-and-file-pointer)
File pointer:
It is high level interface
Passed to fread() and fwrite() functions
Includes buffering,error indication and EOF detection,etc.
Provides higher portability and efficiency.
File descriptor:
Low/Kernel level handler
passe to read() and write() of UNIX System Calls
Doesn't include buffering and such features
Less portable and lacks efficiency
socket.accept() ,接受一个连接,但前提是socket必须已经绑定了一个地址,在等待连接。返回值是一个(conn, addresss)的值对,这里的conn是一个socket对象,可以用来改送或接收数据.而address是连接另一端绑定的地址,socket.getpeername()函数也能返回该地址。
socket.bind(address),将socket对象绑定到一个地址,但这个地址必须是没有被占用的,否则会连接失败。这里的address一般是一个ip,port对ÿ