如何在python中执行此操作? 有些人喜欢这样。
PacketBuffer[0] := $00;
PacketBuffer[1] := $12;
PacketBuffer[2] := $12;
'SendPacket(ProcessID, @PacketBuffer, TRUE, FALSE);'
答案 0 :(得分:0)
使用套接字模块:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((your_host, your_port))
msg_to_send = 'whatever'
num_sent = 0
while num_sent < len(msg_to_send):
sent = s.send(msg_to_send[num_sent:])
if sent == 0:
raise RuntimeError("socket connection broken")
num_sent += sent