~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/server.py

  • Committer: Andrew Bennetts
  • Date: 2008-10-01 05:40:45 UTC
  • mfrom: (3753 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20081001054045-z50qc0d3p9qsc5im
Merge from bzr.dev; resolve osutils.py conflict by reverting my sha import hackery.

Show diffs side-by-side

added added

removed removed

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