Did I find the right examples for you? yes no

All Samples(3)  |  Call(3)  |  Derive(0)  |  Import(0)

        def try_bind(socket, address, port, timeout=30):
    start_time = time.time()
    while (time.time() - start_time) < timeout:
        try:
            return socket.bind((address, port))
        except:
            time.sleep(1)
            # try one last time, just to throw up an exception...
    return socket.bind((address, port))
        


src/y/u/YunBridge-HEAD/bridge/tcp.py   YunBridge(Download)
  def __init__(self, address, port):
    server = socket(AF_INET, SOCK_STREAM)
    server.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    utils.try_bind(server, address, port)
    server.listen(5)

src/y/u/YunBridge-HEAD/bridge/sockets.py   YunBridge(Download)
      server = socket.socket(AF_INET, SOCK_STREAM)
      server.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
      utils.try_bind(server, address, port)
      server.listen(1) # No connection backlog
      server.setblocking(0)

src/y/u/YunBridge-HEAD/bridge/console.py   YunBridge(Download)
  def __init__(self, port=6571):
    server = socket(AF_INET, SOCK_STREAM)
    server.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    utils.try_bind(server, '127.0.0.1', port)
    server.listen(1)  # No connection backlog