April 23rd Summary


服务器:
import socket

sever=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sever.bind(('192.168.12.81',8086))
while True:
date,addr=sever.recvfrom(1024)
print('来自客户端%s:%s的消息:%s'%(addr[0],addr[1],date.decode('utf-8')))
msg=input('>>:').strip()
sever.sendto(msg.encode('utf-8'),addr)
sever.close()

客户端:
import socket
client=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
while True:
msg=input('>>:').strip()
client.sendto(msg.encode('utf-8'),('192.168.12.81',8086))
date,addr=client.recvfrom(1024)
print(date.decode(utf-8))
client.close()

multi-channel technology: want the effect of concurrent execution of multiple processes on a single CPU
Time-sharing operating system: multiple online terminals + multi-channel technology


CPU encounters IO operation switching is to improve efficiency , the
process running time is too long, and the CPU switching process reduces the efficiency

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324818927&siteId=291194637