我花了很多时间使用不同的库,并试图连接到Minecraft服务器,监听端口25565,以发送可能在聊天中显示的数据包。 到目前为止,我还没有成功。我能做到这一点的唯一例子是在我自己的局域网内,但没有人能看到聊天信息。在
有没有通过Python认证Minecraft并向服务器和25565端口发送聊天包?很明显,我不能在打开套接字时在线,因为在关闭之前,同一IP和端口上一次只能有一个连接。在
我所掌握的代码的最直截了当的版本可能是:
from __future__ import absolute_import
import socket
import select
import sys
import atexit
import os
import codecs
import platform
import base64
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
address = '<EXAMPLE ADDRESS HERE>'
port = 25565
print(address)
print(port)
try:
soc.connect((address, port))
print('Successful connection to server!')
try:
soc.sendall(b"Hello, I am a TCP Socket!")
print('(Successfully sent message to the server)')
data = soc.recv(1024)
dc = data.decode('utf-8')
soc.close()
except Exception as e:
print('Failed!')
print(e.message)
except Exception as e:
print('Failed to connect')
目前没有回答
相关问题 更多 >
编程相关推荐