Python (second network programming)

Limit json format

  1. key json format must be a string data type
  2. All documents must be the string ""
    If the number is key, it will be forced to dump after converting to a string data type
    json support tuples, dictionaries will do value tuples of tuples mandatory conversion into lists, tuples can not as the key
    can dump times, but not Load, but have to be if use json dump module, preferably with writing dumps, loads output
    dic = { '1': 'Chinese', '. 3':}. 4
    str_dic = json .dumps (dic, ensure_ascii = False) in the face of Chinese, to use ensure_ascii = False

Since the program you want to communicate on different machines, so had a network
server - has been running, waiting for service to others
clients - use the time to start the service
c / s architecture - client and server are present,
b / S architecture - Browse end mode
b / s architecture c / s architecture relationship -b / s architecture is a branch of c / s architecture,
four 8-bit binary composition, so most will 2,550,000,000,000,000,000 00000000 00000000
appear switches, such multiple the machine complete communication
arp- ARP (the relationship between the query ip address mac address)
gateway - LAN machines, you want access to the machine outside the LAN
ports - could not find the corresponding program 0-65535 different programs at the same time enable same port
ip + port - to distinguish between different services
tcp- three-way handshake
tcp reliable, connection-oriented protocol, full duplex communication, a byte-oriented stream
udp unreliable, connectionless service, high transmission efficiency, one pair of many, many-to-many, message-oriented, do our best service.
ip protocol belongs to network layer protocols in seven
tcp, udp belongs to the transport layer
arp belongs to the data link layer
ip- machine at a location on the network
port number - network-related programs, and to open up a network communications port, the only program able to find a
port occupied on the same machine at the same time, the program takes up only one port
start to open a process
join the main process waits for the child process was performed after the child process ends
daemon daemon needs to be set before the start, when the end of the primary process, all processes end
p.daemon = True
after the daemon process with the end of the main code de end, will not have to wait for another child process, the end of the primary process, the child process ended with
a normal child process was not completed at the time of execution was the main process should have been waiting
daemon, the child can no longer turn a child process
exist is_alive true representative of the process, there is no process for false
terminate the end of a process, but this process will not be killed immediately
lock is to ensure data security in concurrent programming
lock.acquire () need to lock the keys
lock.release () to release the lock, but also the key

Published 17 original articles · won praise 2 · Views 3522

Guess you like

Origin blog.csdn.net/Aidang/article/details/95727567