import zmq
import signal
import sys

port = 5556
context = zmq.Context()
socket = context.socket(zmq.PAIR)
socket.connect("tcp://172.18.0.1:%s" % port)
socket.send_string("hello")

def handler(signal, frame):
    print('exiting...')
    socket.disconnect("tcp://172.18.0.1:%s" % port)
    exit()

signal.signal(signal.SIGINT, handler)

reward = socket.recv()
next_input = socket.recv()

while True:
    socket.send_string("a") # your attempt to solve the current task
    reward = socket.recv()
    next_input = socket.recv()
    print(reward)

signal.pause()

@@ -33,122 +33,804 @@
 sys%0A
-%0Aport = 5556%0Acontext = zmq.Context()%0Asocket = context.socket(zmq.PAIR)%0Asocket.connect(%22tcp://172.18.0.1:%25s%22 %25 port
+import getopt%0A%0A%0Ahost = '172.18.0.1'%0Aport = 5556%0A%0Atry:%0A    opts, args = getopt.getopt(sys.argv%5B1:%5D, 'a:p:', %5B'address=', 'port='%5D)%0Aexcept getopt.GetoptError:%0A    print(%22Error reading options. Usage:%22)%0A    print(%22  example_learner.py %5B-a %3Caddress%3E -p %3Cport%3E%5D%22)%0A    sys.exit(2)%0A%0Afor opt, arg in opts:%0A    if opt in ('-a', '--address'):%0A        host = arg%0A    elif opt in ('-p', '--port'):%0A        try:%0A            port = int(arg)%0A            if port %3C 1 or port %3E 65535:%0A                raise ValueError(%22Out of range%22)%0A        except ValueError:%0A            print(%22Invalid port number: %25s%22 %25 arg)%0A            sys.exit(2)%0A%0Acontext = zmq.Context()%0Asocket = context.socket(zmq.PAIR)%0A%0Aaddress = %22tcp://%25s:%25s%22 %25 (host, port)%0Aprint(%22Connecting to %25s%22 %25 address)%0Asys.stdout.flush()%0A%0Asocket.connect(address
 )%0Aso
@@ -856,16 +856,17 @@
 ello%22)%0A%0A
+%0A
 def hand
@@ -935,36 +935,15 @@
 ect(
-%22tcp://172.18.0.1:%25s%22 %25 port
+address
 )%0A  
@@ -952,16 +952,17 @@
 exit()%0A%0A
+%0A
 signal.s
@@ -1082,16 +1082,17 @@
 ing(%22a%22)
+ 
  # your 

allow to specify address and port via options