34 lines
712 B
Python
34 lines
712 B
Python
import asyncore
|
|
from textwrap import wrap
|
|
|
|
refserver_hostname = "79.172.5.168"
|
|
refserver_port = 4001
|
|
|
|
class REFClient(asyncore.dispatcher):
|
|
buff = ''
|
|
|
|
def __init__(self, host, port):
|
|
asyncore.dispatcher.__init__(self)
|
|
self.create_socket()
|
|
self.connect( (host, port) )
|
|
|
|
def handle_connect(self):
|
|
pass
|
|
|
|
def handle_close(self):
|
|
self.close()
|
|
|
|
def handle_read(self):
|
|
hex = bytes.hex(self.recv(8192))
|
|
hex = wrap(hex, 2)
|
|
print(' '.join(hex))
|
|
|
|
if __name__ == "__main__":
|
|
client = REFClient(refserver_hostname, refserver_port)
|
|
|
|
try:
|
|
asyncore.loop()
|
|
except KeyboardInterrupt:
|
|
pass
|
|
|
|
print("Server stopped.") |