[英]How to get minecraft status?
What's wrong? 怎么了? I recieve nothing. 我什么也没收到。 I have also tried with other Minecraft-servers. 我也尝试过使用其他Minecraft服务器。
import socket
from struct import pack, unpack
host = socket.gethostbyname("localhost")
port = 25565
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
packet = ""
packet += pack('i',4)
packet += pack('p',host)
packet += pack('H',port)
packet += pack('i',1)
s.send(packet)
print s.recv(1024) # Recv nothing ?
I guess this is wrong : 我想这是错误的:
packet += pack('p',host)
packet += pack('H',port)
Replace with this : 替换为:
packet += pack('p',port)
packet += pack('H',host)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.