TCP encoding process: ----- type = SOCK_STREAM
Import module import module
Examples of object instances object socket
Binding IP + port (port) the bind (tuples)
Listen listen ()
Waiting for a connection accept () connected to the server connect / connect_ex (not throw exception, return error codes)
Transceiver send / recv Transceiver
Close close close
UDP encoding process: ----- type = SOCK_DGRAM
Import module import module
Examples of object instances object socket
Binding IP + port (port) bind ()
Transceiver recvfrom / sendto Transceiver
Close Close
TCP and UDP difference
TCP connection-oriented, reliable, byte-oriented fashion, the stick package, only one server at the same time a client end and connected
UDP does not face the connection, unreliable, fast packet-oriented form, non-stick package, and at the same time allows a server connected to a plurality of end customers
Exchange of communication:
broadcast
Unicast
Multicast
TCP occur stick package:
Stick package: the sender after sending data, the receiver does not know how how to accept, resulting in data confusion
Reason: co-sourcing mechanism, unpacking mechanism (occur at the transmitting end)
Five-layer OSI model:
Application layer
Transport Layer
Network layer
The data link layer
Physical Layer