1. Run
How to get to call the operating system command in py code
New Module: subprocess
r = subprocess.Popen('ls',
shell=True,
stdout=subprocess.PIPE
stderr=subprocess.PIPE
Subprocess.Popen # (cmd, shell = True, subprocess.stdout, subprocess.stderr)
#cmd: represents the system command
#shell = True represent this command is a system command tells the operating system, as a system command to execute cmd
After #stdout system command is completed, a pipeline hold the result
#stderr is after the execution of system commands, a village treasure pipeline for errors
print(r.stdout.read().decode('gbk'))
print(r.stderr.read().decode('gbk'))
Stick package problem: only tcp protocol will send stick package, udp does not occur
EX: sender sends data, the receiver does not know how to receive a data caused by the phenomenon of chaos
In the TCP protocol,
There is a co-sourcing mechanism (Nagle algorithm), and transmits a plurality of successive intervals less data, packed into one data transfer
There is a mechanism unpacking mechanism, at the transmitting end, due to the receipt of the MTU limit card, will be larger than the limit data MTU, split, split into a plurality of small data, for transmission. When the transmission to when the target host operating system layer, re-merge the data into multiple small original data
udp stick package does not occur, udp protocol layer to the first transceiver to limit the size of the data is:
65535-ip header (20) -udp header (8) = 65507
Standing on the data link layer, the network card because the MTU typically limited to 1500, so for the data link layer, the size of the primary data transmission and reception is limited to 1500 - ip header (20) -udp header (8) = 1472
came to a conclusion:
If sendto (num)
num> 65507 error
1472 <num <65507 will unpack the data link layer, and udp itself is not reliable protocol, once unpacked, the plurality of small data packets caused by transmission in the network, if any lost, then the data transmission failure
num <1472 is an ideal state