giants-stupid-server/dpnet/netclient.py

18 lines
471 B
Python
Raw Permalink Normal View History

2019-01-22 01:30:42 +01:00
from .packet import Packet
from .EnumQuery import EnumQuery
import socket
import threading
class Netclient:
def __init__(self, ip, port):
self.ip = ip
self.port = port
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
def send(self, packet):
self.socket.sendto(packet.getvalue(), (self.ip, self.port))
print("R>", packet.getvalue().hex())
def receive(self):
return self.socket.recv(4096)