'A factory method which allows subclasses to define the precise
type of socket they want.'

def makeSocket(self, timeout=1):

    if (self.port is not None):
        result = socket.create_connection(self.address, timeout=timeout)
    else:
        result = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        result.settimeout(timeout)
        try:
            result.connect(self.address)
        except OSError:
            result.close()
            raise
    return result
