import socket
import struct
from threading import Thread
import time

def writeString(toConvert):
	strByte = bytearray(toConvert, "utf-8")
	result = struct.pack("<i", len(strByte)) + strByte
	return result

class Connect:
	def __init__(self, ip, port):
		self.ip = ip
		self.port = port
		self.s = socket.socket()
		self.s.connect((ip,port))
		self.handshake()
		self.thread = Thread(target = self.receive)
		self.thread.start()
	def sendPacket(self, id, data = None):
		if str(type(id)) == "<class 'int'>":
			id = struct.pack("<i", id)
		if (data != None and str(type(data)) == "<class 'bytearray'>") or (data == None):
			if data != None:
				self.s.send(bytes((len(data)+len(id),)))
			else:
				self.s.send(bytes((1,)))
			self.s.send(bytearray(id))
			if data != None:
				self.s.send(data)
		else:
			raise TypeError
	def handshake(self):
		packet = bytearray()
		packet_id = b'\x00'
		packet += struct.pack("<i", 210)
		packet += writeString(self.ip)
		packet += struct.pack("!H", self.port)
		packet += struct.pack("<i", 1)
		self.sendPacket(packet_id, packet)
		self.sendPacket(b'\x00')
	def receive(self):
		while True:
			try:
				response = self.s.recv(4096)
				if response:
					print(str(response))
					print(str(response,"utf-8"))
			except BlockingIOError:
				pass

@@ -243,16 +243,31 @@
 ip, port
+, debug = False
 ):%0A%09%09sel
@@ -533,25 +533,25 @@
 truct.pack(%22
-%3C
+!
 i%22, id)%0A%09%09if
@@ -642,32 +642,155 @@
 f data != None:%0A
+%09%09%09%09if debug:%0A%09%09%09%09%09print(%22Sent: %22 + ''.join(r'%5Cx' + hex(letter)%5B2:%5D for letter in struct.pack(%22!i%22, len(data) + len(id))))%0A
 %09%09%09%09self.s.send(
@@ -793,17 +793,21 @@
 end(byte
-s
+array
 ((len(da
@@ -839,82 +839,348 @@
 %09%09%09%09
-self.s.send(bytes((1,)))%0A%09%09%09self.s.send(bytearray(id))%0A%09%09%09if data != None:
+if debug:%0A%09%09%09%09%09print(%22Sent: %22 + ''.join(r'%5Cx' + hex(letter)%5B2:%5D for letter in bytes((1,))))%0A%09%09%09%09self.s.send(bytes((1,)))%0A%09%09%09if debug:%0A%09%09%09%09print(%22Sent: %22 + ''.join(r'%5Cx' + hex(letter)%5B2:%5D for letter in bytearray(id)))%0A%09%09%09self.s.send(bytearray(id))%0A%09%09%09if data != None:%0A%09%09%09%09print(%22Sent: %22 + ''.join(r'%5Cx' + hex(letter)%5B2:%5D for letter in data))
 %0A%09%09%09
@@ -1313,25 +1313,25 @@
 truct.pack(%22
-%3C
+!
 i%22, 210)%0A%09%09p
@@ -1422,25 +1422,25 @@
 truct.pack(%22
-%3C
+!
 i%22, 1)%0A%09%09sel

Debug Mode + Bug fixes maybe pls?