tcp_socket/_examples_/tcp_socket__stp.py

22 lines
451 B
Python

import sys # nopep8
sys.path.append('../..') # nopep8
import tcp_socket
import report
def mirror_callback(tcp):
tcp.send(tcp.receive())
logger = report.default_logging_config()
# Start the server
s = tcp_socket.tcp_server_stp('127.0.0.1', 17017)
s.register_callback(mirror_callback)
# Start the client
c = tcp_socket.tcp_client_stp('127.0.0.1', 17017)
c.send(b'abc')
print('The Client received: %s' % repr(c.receive()))