Connect to the statsite server

def _connect(self):
        """
        Connect to the statsite server
        """
        # Create socket
        if self.udpport > 0:
            self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            self.port = self.udpport
        elif self.tcpport > 0:
            self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.port = self.tcpport
        if socket is None:
            # Log Error
            self.log.error("StatsiteHandler: Unable to create socket.")
            # Close Socket
            self._close()
            return
        # Set socket timeout
        self.socket.settimeout(self.timeout)
        # Connect to statsite server
        try:
            self.socket.connect((self.host, self.port))
            # Log
            self.log.debug("Established connection to statsite server %s:%d",
                           self.host, self.port)
        except Exception as ex:
            # Log Error
            self.log.error("StatsiteHandler: Failed to connect to %s:%i. %s",
                           self.host, self.port, ex)
            # Close Socket
            self._close()
            return