TCP three-time handshake: SYN------Syn+ack and ACK
Four waves: fin-to-ack (FIN)--and ACK
TCP 10 states: LISTEN syn_sent Syn_recv established fin_wait1 fin_wait2 close_wait last_ack time_wait CLOSED
MSL: Maximum message survival time
4 times the handshake completes the connection close, the active close the connection one party after the 3rd time handshake completes sends the fourth time handshake the ACK packet to enter the TIME_WAIT state, must stay in this state twice the MSL time, waits for 2MSL time the main purpose is afraid the last ACK packet the other party seizes, Then the other side after the timeout will be re-send the third handshake fin bag, active close to the re-issued Fin packet can be sent again an ACK reply packet.
The TCP server model is implemented in several ways: single-process non-clogging: Use Select.setblocking () to turn sockets into non-clogging types.
Using Select to implement Select.select () can be polled to ask which sockets have tasks. (Send and receive data, exception)
Epoll:select.epoll () time notification mechanism, greatly improved efficiency
coprocessor : The Greenlet module in Python is similar to a thread but not equal to a thread, and requires Greenlet.switch () to switch the calling process manually.
If you want to switch automatically, use gevent:gevent to rewrite the time-consuming stuff (functions, classes). So you can only use it inside to achieve the time-consuming operation, such as Gevent.socket (), Gevent.sleep (), to create a co-process With Gevent.spawn (), you need to add a sentence before executing the code gevent.monkey.patch_all () it will modify the code, recompile, so that the process can be manipulated like a thread. It's just a time-consuming operation to switch back and forth.
PYTHON__ System: Socket_tcp Supplement, co-process