def connect(self):
        self.setup_smb_server()
        if self.__smb_server.is_login_required():
            if self._password != '' or (self._password == '' and self._nt_hash == '' and self._lm_hash == ''):
                self.__smb_server.login(self._username, self._password)
            elif self._nt_hash != '' or self._lm_hash != '':
                self.__smb_server.login(self._username, '', '', self._lm_hash, self._nt_hash)
        self.__tid = self.__smb_server.tree_connect_andx('\\\\*SMBSERVER\\IPC$')
        self.__handle = self.__smb_server.nt_create_andx(self.__tid, self.__filename)
        # self.__handle = self.__smb_server.open_file_andx(self.__tid, r"\\PIPE\%s" % self.__filename, smb.SMB_O_CREAT, smb.SMB_ACCESS_READ)[0]
        # self.__handle = self.__smb_server.open_file(self.__tid, r"\\PIPE\%s" % self.__filename, smb.SMB_O_CREAT, smb.SMB_ACCESS_READ)[0]
        self.__socket = self.__smb_server.get_socket()
        return 1