def METHOD_NAME(self, port):
    """
    Attempts to bind to the requested communicator port, checking if it is already in use.
    """
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    if platform == "linux" or platform == "linux2":
        # On linux, the port remains unusable for TIME_WAIT=60 seconds after closing
        # SO_REUSEADDR frees the port right after closing the environment
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    try:
        s.bind(("localhost", port))
    except OSError:
        raise UnityWorkerInUseException(self.worker_id)
    finally:
        s.close()