def start_server(port):
    ''' binds to a port, waits for the debugger to connect '''
    s = socket(AF_INET, SOCK_STREAM)
    s.settimeout(None)

    try:
        from socket import SO_REUSEPORT
        s.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)
    except ImportError:
        s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)

    s.bind(('', port))
    pydev_log.info("Bound to port :%s", port)

    try:
        s.listen(1)
        newSock, _addr = s.accept()
        pydev_log.info("Connection accepted")
        # closing server socket is not necessary but we don't need it
        s.shutdown(SHUT_RDWR)
        s.close()
        return newSock

    except:
        pydev_log.exception("Could not bind to port: %s\n", port)
def start_server ( port ) : s = socket ( AF_INET , SOCK_STREAM ) s . settimeout ( None ) try : from socket import SO_REUSEPORT s . setsockopt ( SOL_SOCKET , SO_REUSEPORT , 1 ) except ImportError : s . setsockopt ( SOL_SOCKET , SO_REUSEADDR , 1 ) s . bind ( ( '' , port ) ) pydev_log . info ( "Bound to port :%s" , port ) try : s . listen ( 1 ) newSock , _addr = s . accept ( ) pydev_log . info ( "Connection accepted" ) s . shutdown ( SHUT_RDWR ) s . close ( ) return newSock except : pydev_log . exception ( "Could not bind to port: %s\n" , port )
binds to a port, waits for the debugger to connect