MFC实现客户端向服务器传送文件
下面是一个基于MFC框架的客户端向服务器传送文件的完整源码:
// ClientDlg.h : header file
//
#pragma once
#include <afxsock.h>
// CClientDlg dialog
class CClientDlg : public CDialogEx
{
// Construction
public:
CClientDlg(CWnd* pParent = nullptr); // standard constructor
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_CLIENT_DIALOG };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;
CSocket m_clientSocket;
CString m_strServerAddress;
UINT m_nServerPort;
CString m_strFilePath;
BOOL CheckFileExists();
BOOL ConnectToServer();
BOOL SendFile();
void CloseConnection();
// Generated message map functions
virtual BOOL O