def connect(self):
        """
        Connect to TCP or domain socket, and process the server LMTP greeting.

        """
        # extract proto from socket setting
        try:
            (proto, spec) = self.socket.split(':')
        except ValueError:
            raise DspamClientError(
                'Failed to parse DSPAM socket specification, '
                'no proto found: ' + self.socket)

        if proto == 'unix':
            # connect to UNIX domain socket
            try:
                self._socket = socket.socket(
                    socket.AF_UNIX, socket.SOCK_STREAM)
                self._socket.connect(spec)
            except socket.error as err:
                self._socket = None
                raise DspamClientError(
                    'Failed to connect to DSPAM server '
                    'at socket {}: {}'.format(spec, err))
            logger.debug('Connected to DSPAM server at socket {}'.format(spec))

        elif proto == 'inet' or proto == 'inet6':
            # connect to TCP socket
            try:
                (port, host) = spec.split('@')
                port = int(port)
                if host == '':
                    host = 'localhost'
            except ValueError:
                port = int(spec)
                host = 'localhost'

            try:
                self._socket = socket.socket(
                    socket.AF_INET, socket.SOCK_STREAM)
                self._socket.connect((host, port))
            except socket.error as err:
                self._socket = None
                raise DspamClientError(
                    'Failed to connect to DSPAM server at host {} '
                    'port {}: {}'.format(host, port, err))
            logger.debug(
                'Connected to DSPAM server at host {}, port {}'.format(
                    host, port))
        else:
            raise DspamClientError(
                'Failed to parse DSPAM socket specification, '
                'unknown proto ' + proto)

        resp = self._read()
        if not resp.startswith('220'):
            raise DspamClientError(
                'Unexpected server response at connect: ' + resp)
Connect to TCP or domain socket, and process the server LMTP greeting.