Skip to content

Commit

Permalink
Same
Browse files Browse the repository at this point in the history
  • Loading branch information
FewerElk authored Aug 12, 2024
1 parent b9c4d07 commit b361e2d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ def pack_data(d):
d = bytes(d, "utf-8")
return h + d


def pack_port(i):
return struct.pack('>H', i)


def get_info(host='localhost', port=25565):

# Connect
Expand All @@ -43,7 +45,7 @@ def get_info(host='localhost', port=25565):
# Read response
print(f"Packet lenth : {unpack_varint(s)}") # Packet length
print(f"Packet ID : {unpack_varint(s)}") # Packet ID
l = unpack_varint(s) # String length
l = unpack_varint(s) # String length
print(f"String lenth : {l}")

d = b""
Expand All @@ -57,8 +59,8 @@ def get_info(host='localhost', port=25565):
print(d)
return json.loads(d.decode('utf-8'))

def get_info2(host='localhost', port=25565):

def get_info2(host='localhost', port=25565):
# Connect
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
Expand All @@ -71,4 +73,5 @@ def get_info2(host='localhost', port=25565):

return f"{len(a)} --> {a}"

print(get_info(host="localhost", port=25565))

print(get_info(host="localhost", port=25565))

0 comments on commit b361e2d

Please sign in to comment.