Skip to content

Instantly share code, notes, and snippets.

@stevommmm
Created November 1, 2012 00:03
Show Gist options
  • Select an option

  • Save stevommmm/3990766 to your computer and use it in GitHub Desktop.

Select an option

Save stevommmm/3990766 to your computer and use it in GitHub Desktop.
Minecraft server list ping handler
#!/usr/bin/python
import asyncore, socket, pickle
class Server(asyncore.dispatcher):
def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.bind(('', port))
self.listen(1)
def handle_accept(self):
socket, address = self.accept()
print 'Connection by', address
EchoHandler(socket)
class EchoHandler(asyncore.dispatcher_with_send):
# Wait for attempted connections and respond with out server list ping pickle
# (Should probably double check it is the server list ping packet)
def handle_read(self):
d = self.recv(1024)
if d:
self.send(pickle.loads("""S'\xff\x00.\x00\xa7\x001\x00\x00\x004\x007\x00\x00\x001\x00.\x009\x00.\x002\x00\x00\x00 \x00D\x00e\x00a\x00y\x00g\x00o\x00 \x00S\x00m\x00e\x00l\x00l\x00s\x00\x00\x001\x000\x000\x00\x00\x001\x000\x000'
p0
."""))
s = Server('', 25565)
asyncore.loop()
@Bytekron
Copy link
Copy Markdown

I use a kinda similar ping for those minecraft server lists
Minecraft Server Buzz and Minelist

Of course this python ping script is pretty old, but in the core its still works the same as 14 years ago.

Appreciate your work sharing with the community, thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment