first commit
This commit is contained in:
34
divs/tcp_monitor.py
Normal file
34
divs/tcp_monitor.py
Normal file
@@ -0,0 +1,34 @@
|
||||
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.")
|
||||
Reference in New Issue
Block a user