计算机网络课程设计报告-利用c实现smtp协议内容摘要:

6)。 char_array_4[3] = char_array_3[2] amp。 0x3f。 for (j = 0。 (j i + 1)。 j++) ret += base64_chars[char_array_4[j]]。 //这个字符串是 乱码把 6 个字节放在 8 个字节的空间里 while((i++ 3)) ret += 39。 =39。 } return ret。 } std::string Base64::base64_decode(std::string constamp。 decode_string) { return base64_decode((const unsigned char *)(), ())。 } // : implementation file // include include include include ifdef _DEBUG define new DEBUG_NEW undef THIS_FILE static char THIS_FILE[] = __FILE__。 endif CServerSocket::CServerSocket() { } CServerSocket::~CServerSocket() { } // Do not edit the following lines, which are needed by ClassWizard. if 0 BEGIN_MESSAGE_MAP(CServerSocket, CAsyncSocket) //{{AFX_MSG_MAP(CServerSocket) //}}AFX_MSG_MAP END_MESSAGE_MAP() endif // CServerSocket member functions void CServerSocket::SetParent(CDialog *pWnd) { m_pWnd = pWnd。 } void CServerSocket::OnReceive(int nErrorCode) { // TODO: Add your specialized code here and/or call the base class if (nErrorCode == 0) ((CSMTPSeverDlg*)m_pWnd)OnReceive()。 东 北大学秦皇岛分校课程设计 第 9 页 AsyncSelect(FD_READ)。 CAsyncSocket::OnReceive(nErrorCode)。 } void CServerSocket::OnClose(int nErrorCode) { // TODO: Add your specialized code here and/or call the base class if (nErrorCode == 0) ((CSMTPSeverDlg*)m_pWnd)OnClose()。 CAsyncSocket::OnClose(nErrorCode)。 } // : implementation file // include include include include ifdef _DEBUG define new DEBUG_NEW undef THIS_FILE static char THIS_FILE[] = __FILE__。 endif CListenerSocket::CListenerSocket() { } CListenerSocket::~CListenerSocket() { } // Do not edit the following lines, which are needed by ClassWizard. if 0 BEGIN_MESSAGE_MAP(CListenerSocket, CAsyncSocket) //{{AFX_MSG_MAP(CListenerSocket) //}}AFX_MSG_MAP END_MESSAGE_MAP() endif // 0 // CListenerSocket member functions void CListenerSocket::SetParent(CDialog *pWnd) { m_pWnd = pWnd。 } void CListenerSocket::OnAccept(int nErrorCode) { if (nErrorCode == 0) ((CSMTPSeverDlg*)m_pWnd)OnAccept()。 CAsyncSocket::OnAccept(nErrorCode)。 } 客户端相关代码: 1)、相关核心代码如下: // : implementation file include include include include .\lib\ include .\lib\ 东 北大学秦皇岛分校课程设计 第 10 页 include ifdef _DEBUG define new DEBUG_NEW undef THIS_FILE static char THIS_FILE[] = __FILE__。 endif static TCHAR _szFilter[] = TEXT(All Files\0*.*\0Text Files (*.txt)\0*.TXT\0)。 ///////////////////////////////////////////////////////////////////////////// class CAboutDlg : public CDialog { public: CAboutDlg()。 // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }。 //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX)。 // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP() }。 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX)。 //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CEMailDlg dialog CEMailDlg::CEMailDlg(CWnd* pParent /*=NULL*/) : CDialog(CEMailDlg::IDD, pParent) { //{{AFX_DATA_INIT(CEMailDlg) m_to = _T()。 m_subject = _T()。 m_from = _T()。 m_content = _T()。 m_cc = _T()。 m_bcc = _T()。 //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_bIsSetup = FALSE。 东 北大学秦皇岛分校课程设计 第 11 页 //m_hIcon = AfxGetApp()LoadIcon(IDR_MAINFRAME)。 m_hIcon = AfxGetApp()LoadIcon(IDI_MAIL)。 } void CEMailDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX)。 //{{AFX_DATA_MAP(CEMailDlg) DDX_Control(pDX, IDC_LIST_FILE, m_ListBox)。 DDX_Text(pDX, IDC_EDIT_TO, m_to)。 DDX_Text(pDX, IDC_EDIT_SUBJECT, m_subject)。 DDX_Text(pDX, IDC_EDIT_FROM, m_from)。 DDX_Text(pDX, IDC_EDIT_CONTENT, m_content)。 DDX_Text(pDX, IDC_EDIT_CC, m_cc)。 DDX_Text(pDX, IDC_EDIT_BCC, m_bcc)。 //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CEMailDlg, CDialog) //{{AFX_MSG_MAP(CEMailDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BUTTON_ADD_FILE, OnButtonAddFile) ON_BN_CLICKED(IDC_BUTTON_SEND, OnButtonSend) ON_BN_CLICKED(IDC_BUTTON_SETUP, OnButtonSetup) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CEMailDlg message handlers BOOL CEMailDlg::OnInitDialog() { CDialog::OnInitDialog()。 // Add About... menu item to system menu. // IDM_ABOUTBOX must be in the system mand range. ASSERT((IDM_ABOUTBOX amp。 0xFFF0) == IDM _ABOUTBOX)。 ASSERT(IDM_ABOUTBOX 0xF000)。 CMenu* pSysMenu = GetSystemMenu(FALSE)。 if (pSysMenu != NULL) { CString strAboutMenu。 (IDS_ABOUTBOX)。 if (!()) { pSysMenuAppendMenu(MF_SEPARATOR)。 pSysMenuAppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu)。 } } // Set the icon for this dialog. The framework does this automatically // when the application39。 s main window is not a dialog SetIcon(m_hIcon, TRUE)。 // Set big icon SetIcon(m_hIcon, FALSE)。 // Set small icon // TODO: Add extra initialization here stat。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。