import sys                  # nopep8
sys.path.append('../..')    # nopep8
import time
import tcp_socket
import report


def mirror_callback(tcp):
    tcp.send(tcp.receive())


logger = report.default_logging_config()
s = tcp_socket.tcp_server_stp('127.0.0.1', 17017)
s.register_callback(mirror_callback)

i = 0
while not s.is_connected() and i <= 10:
    i += 1
    time.sleep(.1)  # wait for a connection

i = 0
while s.is_connected() and i <= 10:
    i += 1
    time.sleep(.1)  # wait for disconnect
