问题描述:题如下,由于刚接触网络编程,我不知道我的做法是否正确,还请赐教
import socket
import pickle
def main(msg):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('', 11264))
s.sendto(pickle.dumps(msg), ('127.0.0.1', 11264))
data, addr = s.recvfrom(1024)
s.close()
data = pickle.loads(data)
return data
请问这样的做法是否正确?