import socket
import time
import datetime
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.settimeout(60)
s.connect(("192.168.137.3",8080))
dt = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print dt
time.sleep(10)
s.send('aaaaaaaaaaaaaaa')
dt = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print dt
print "packet send!"
print s.recv(100)
dt = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print dt
C:\Python27\python.exe C:/Users/TLCB/PycharmProjects/untitled2/socket/t200.py
2022-02-05 18:33:07
2022-02-05 18:33:17
packet send!
response:aaaaaaaaaaaaaaa_15
2022-02-05 18:33:36
执行 send 发送的字节,会立马发送吗?
答案是不确定!执行 send 之后,数据只是拷贝到了socket 缓冲区。至 于什么时候会发数据,发多少数据,全听操作系统安排