Commit c1dfb938 authored by Ignacio Corderi's avatar Ignacio Corderi
Browse files

Added IPv6 support (Issue #8)

parent fa4a9b1c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@ Changes since 0.7.1
===========================
This section will document changes to the library since the last release

## New features
- Added IPv6 address support on all clients (Issue #8)

## Bug Fixes
- Fixex bug that caused close() and connect() to fail on a connection that faulted (Issue #7)
- Fixed a bug that caused the AsyncClient to crash when calling close()
+2 −2
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@ class AsyncClient(baseasync.BaseAsync):
        self.max_pending = MAX_PENDING
        self.closing = False

    def build_socket(self):
        return socket.socket()
    def build_socket(self, family=socket.AF_INET):
        return socket.socket(family)

    def connect(self):
        super(AsyncClient, self).connect()
+8 −4
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import struct
import common
import kinetic_pb2 as messages

ss = socket

LOG = logging.getLogger(__name__)

def calculate_hmac(secret, message):
@@ -105,21 +107,23 @@ class BaseClient(object):
    def isConnected(self):
        return not self._closed

    def build_socket(self):
       return socket.socket()
    def build_socket(self, family=ss.AF_INET):
       return socket.socket(family)

    def connect(self):
        if self._socket:
            raise common.AlreadyConnected("Client is already connected.")

        infos = socket.getaddrinfo(self.hostname, self.port, 0, 0, socket.SOL_TCP)
        (family,_,_,_, sockaddr) = infos[0]
        # Stage socket on a local variable first
        s = self.build_socket()
        s = self.build_socket(family)
        s.settimeout(self.connect_timeout)
        if self.socket_address:
            LOG.debug("Client local port address bound to " + self.socket_address)
            s.bind((self.socket_address, self.socket_port))
        # if connect fails, there is nothing to clean up
        s.connect((self.hostname, self.port))
        s.connect(sockaddr) # use first
        s.settimeout(self.socket_timeout)

        # We are connected now, update attributes