def listen():
    """
    Initial setup, runs once
    """
    global listener

    # Server's listener socket
    listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    # get and recv buffer size to print below, just FYI
    rcvbuf = listener.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF)

    # Ensure we release listener socket immediately when program exits, 
    #  to avoid socket.error: [Errno 48] Address already in use
    listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

    # Listen, prepare for senders to connect
    listener.bind(('localhost', port))
    listener.listen(1) 
    print '\nServer listens on localhost port %s with RCVBUF size %s' % (port, rcvbuf)


# Define function for sender connect - also used in stepper reset()
dataset/ETHPy150Open jon-jacky/PyModel/samples/Socket/stepper_util.py/listen/original