~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/server.py

Merge with get_file_sha1

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        from socket import error as socket_error
60
60
        self._socket_error = socket_error
61
61
        self._socket_timeout = socket_timeout
62
 
        self._server_socket = socket.socket()
 
62
        addrs = socket.getaddrinfo(host, port, socket.AF_UNSPEC, 
 
63
            socket.SOCK_STREAM, 0, socket.AI_PASSIVE)[0]
 
64
 
 
65
        (family, socktype, proto, canonname, sockaddr) = addrs
 
66
 
 
67
        self._server_socket = socket.socket(family, socktype, proto)
63
68
        # SO_REUSERADDR has a different meaning on Windows
64
69
        if sys.platform != 'win32':
65
70
            self._server_socket.setsockopt(socket.SOL_SOCKET,
66
71
                socket.SO_REUSEADDR, 1)
67
72
        try:
68
 
            self._server_socket.bind((host, port))
 
73
            self._server_socket.bind(sockaddr)
69
74
        except self._socket_error, message:
70
75
            raise errors.CannotBindAddress(host, port, message)
71
76
        self._sockname = self._server_socket.getsockname()