- 浏览: 2533335 次
文章分类
最新评论
-
rasonyang:
要早点更换,我也不至于 现在 用 freeswitch。 c ...
asterisk 终于要替换SIP协议栈了 -
redhacker:
你好,博主!你安装后破解了吗?
IBM RSA (IBM rational software architect ) V8 学习之一 安装 -
canghaifuyun1987:
lz 我来关注下你呗,写的好
Spring Aop例子(实现接口) -
zhaoshijie:
请问 这种方式可以拦截到目标方法:ClassPathXmlAp ...
Spring3.0中的AOP注解配置 -
jiji87432:
谢谢分享,有很大帮助。
post和get的区别
使用CAsyncSocket类进行网络编程
1 服务器端
由先得专门为服务器端做一个Socket通信类CNewSocket类,此类继承CAsyncSocket类,专门负责服务器端socket通信事情:
NewSocket.h:
#pragma once #include "afxsock.h" //此类专门用来与客户端进行socket通信 class CNewSocket : public CAsyncSocket { public: CNewSocket(void); ~CNewSocket(void); virtual void OnReceive(int nErrorCode); virtual void OnSend(int nErrorCode); // 消息长度 UINT m_nLength; //消息缓冲区 char m_szBuffer[4096]; };
对应实现代码如下:
NewSocket.cpp:
#include "StdAfx.h" #include "NewSocket.h" CNewSocket::CNewSocket(void) : m_nLength(0) { memset(m_szBuffer,0,sizeof(m_szBuffer)); } CNewSocket::~CNewSocket(void) { if(m_hSocket !=INVALID_SOCKET) { Close(); } } void CNewSocket::OnReceive(int nErrorCode) { // TODO: Add your specialized code here and/or call the base class m_nLength =Receive(m_szBuffer,sizeof(m_szBuffer),0); //接收数据 m_szBuffer[m_nLength] ='\0'; //接收消息后就开始给客户端发相同的消息 AsyncSelect(FD_WRITE); //触发OnSend函数 CAsyncSocket::OnReceive(nErrorCode); } void CNewSocket::OnSend(int nErrorCode) { // TODO: Add your specialized code here and/or call the base class char m_sendBuf[4096]; //消息缓冲区 strcpy(m_sendBuf,"server send:"); strcat(m_sendBuf,m_szBuffer); Send(m_sendBuf,strlen(m_sendBuf)); //触发OnReceive函数 AsyncSelect(FD_READ); CAsyncSocket::OnSend(nErrorCode); }
如上,NewSocket类重载了CAsyncSocket类的接收与发送事件处理例程,一旦被触发了发送或接收事件,将调用此对应函数.
接下来服务器端在做一个专门类CListenSocket类,用来监听来自客户端的连接请求,如下:
ListenSocket.h:
#pragma once #include "afxsock.h" #include "NewSocket.h" class CListenSocket : public CAsyncSocket { public: CListenSocket(void); ~CListenSocket(void); CNewSocket *m_pSocket; //指向一个连接的socket对象 virtual void OnAccept(int nErrorCode); };由上可知,CListenSocket类还是继承了CAsyncSocket类,并重载了其接受事件,且包含了一个由之前定义好的CNewSocket类指针做为成员,用来指向与客户端连接好的连接.
其实现代码如下:
ListenSocket.cpp:
#include "StdAfx.h" #include "ListenSocket.h" CListenSocket::CListenSocket(void) { } CListenSocket::~CListenSocket(void) { } void CListenSocket::OnAccept(int nErrorCode) { // TODO: Add your specialized code here and/or call the base class CNewSocket *pSocket =new CNewSocket(); if(Accept(*pSocket)) { pSocket->AsyncSelect(FD_READ); //触发通信socket的Read函数读数据 m_pSocket =pSocket; } else { delete pSocket; } CAsyncSocket::OnAccept(nErrorCode); }
这个OnAccept事件触发是在Listen之后,如果有客户端尝试连接时触发,且先看后续内容.
接下来就是对话框的代码了:
SocketServerDlg.h:
// SocketServerDlg.h : header file // #pragma once #include "ListenSocket.h" // CSocketServerDlg dialog class CSocketServerDlg : public CDialogEx { // Construction public: CSocketServerDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data enum { IDD = IDD_SOCKETSERVER_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support CListenSocket m_srvrSocket; //监听套接字 // Implementation protected: HICON m_hIcon; // Generated message map functions virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClickedBtStart(); };在这个CSocketServerDlg类的声明内包含了一个CListenSocket成员m_srvrSocket,并有一个start按键.
// SocketServerDlg.cpp : implementation file // #include "stdafx.h" #include "SocketServer.h" #include "SocketServerDlg.h" #include "afxdialogex.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CAboutDlg dialog used for App About class CAboutDlg : public CDialogEx { public: CAboutDlg(); // Dialog Data enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) END_MESSAGE_MAP() // CSocketServerDlg dialog CSocketServerDlg::CSocketServerDlg(CWnd* pParent /*=NULL*/) : CDialogEx(CSocketServerDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CSocketServerDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CSocketServerDlg, CDialogEx) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BT_START, &CSocketServerDlg::OnBnClickedBtStart) END_MESSAGE_MAP() // CSocketServerDlg message handlers BOOL CSocketServerDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { BOOL bNameValid; CString strAboutMenu; bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); ASSERT(bNameValid); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application'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 return TRUE; // return TRUE unless you set the focus to a control } void CSocketServerDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialogEx::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CSocketServerDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialogEx::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR CSocketServerDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CSocketServerDlg::OnBnClickedBtStart() { // TODO: Add your control notification handler code here if(m_srvrSocket.m_hSocket ==INVALID_SOCKET) { //创建监听套接字,激发FD_ACCEPT事件,默认端口7190 BOOL bFlag =m_srvrSocket.Create(7190,SOCK_STREAM,FD_ACCEPT); //第三个参数表示m_srvrSocket只对FD_ACCEPT事件感兴趣 if(!bFlag) { AfxMessageBox(_T("Socket创建失败!")); m_srvrSocket.Close(); PostQuitMessage(0); return; } GetDlgItem(IDC_BT_START)->EnableWindow(FALSE); //监听成功,等待连接请求 if(!m_srvrSocket.Listen())//如果监听失败 { int nErrorCode =m_srvrSocket.GetLastError(); //检测错误信息 if(nErrorCode !=WSAEWOULDBLOCK) //如果不是线程阻塞 { AfxMessageBox(_T("Socket错误!")); m_srvrSocket.Close(); PostQuitMessage(0); return; } } } }
当用户按下start按键时,程序首先调用m_srvrSocket的Create函数创建一个socket,然后调用它的Listen函数监听客户端的连接请求,一旦客户端尝试连接服务器,那将触发m_srvrSocket的FD_ACCEPT事件.接着在m_srvrSocket的OnAccept函数内,将创建一个CNewSocket对象,并利用此对象来操作socket收发,到此,服务器端的代码完.
2 客户端
这里的客户端的功能就是与服务器建立连接,交用户的数据发送给服务器,并显示来自服务器的接收数据.
与服务器类似,首先做一个专门用于socket通信的类ClientSocket类:
ClientSocket.h:
#pragma once #include "afxsock.h" class ClientSocket : public CAsyncSocket { public: ClientSocket(void); ~ClientSocket(void); // 是否连接 bool m_bConnected; // 消息长度 UINT m_nLength; //消息缓冲区 char m_szBuffer[5096]; virtual void OnConnect(int nErrorCode); virtual void OnReceive(int nErrorCode); virtual void OnSend(int nErrorCode); };由上类声明可知,此类重载了CAsyncSocket的连接,接收,发送事件例程.其实现代码如下:
#include "StdAfx.h" #include "ClientSocket.h" #include "SocketTest.h" #include "SocketTestDlg.h" ClientSocket::ClientSocket(void) : m_bConnected(false) , m_nLength(0) { memset(m_szBuffer,0,sizeof(m_szBuffer)); } ClientSocket::~ClientSocket(void) { if(m_hSocket !=INVALID_SOCKET) { Close(); } } void ClientSocket::OnConnect(int nErrorCode) { // TODO: Add your specialized code here and/or call the base class //连接成功 if(nErrorCode ==0) { m_bConnected =TRUE; //获取主程序句柄 CSocketTestApp *pApp =(CSocketTestApp *)AfxGetApp(); //获取主窗口 CSocketTestDlg *pDlg =(CSocketTestDlg *)pApp->m_pMainWnd; //在主窗口输出区显示结果 CString strTextOut; strTextOut.Format(_T("already connect to ")); strTextOut +=pDlg->m_Address; strTextOut += _T(" 端口号:"); CString str; str.Format(_T("%d"),pDlg->m_Port); strTextOut +=str; pDlg->m_MsgR.InsertString(0,strTextOut); //激活一个网络读取事件,准备接收 AsyncSelect(FD_READ); } CAsyncSocket::OnConnect(nErrorCode); } void ClientSocket::OnReceive(int nErrorCode) { // TODO: Add your specialized code here and/or call the base class //获取socket数据 m_nLength =Receive(m_szBuffer,sizeof(m_szBuffer)); //获取主程序句柄 CSocketTestApp *pApp =(CSocketTestApp *)AfxGetApp(); //获取主窗口 CSocketTestDlg *pDlg =(CSocketTestDlg *)pApp->m_pMainWnd; CString strTextOut(m_szBuffer); //在主窗口的显示区显示接收到的socket数据 pDlg->m_MsgR.InsertString(0,strTextOut); memset(m_szBuffer,0,sizeof(m_szBuffer)); CAsyncSocket::OnReceive(nErrorCode); } void ClientSocket::OnSend(int nErrorCode) { // TODO: Add your specialized code here and/or call the base class //发送数据 Send(m_szBuffer,m_nLength,0); m_nLength =0; memset(m_szBuffer,0,sizeof(m_szBuffer)); //继续提请一个读的网络事件,接收socket消息 AsyncSelect(FD_READ); CAsyncSocket::OnSend(nErrorCode); }
接下来就是对话框代码了:
SocketTestDlg.h:
// SocketTestDlg.h : header file // #pragma once #include "afxwin.h" #include "ClientSocket.h" // CSocketTestDlg dialog class CSocketTestDlg : public CDialogEx { // Construction public: CSocketTestDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data enum { IDD = IDD_SOCKETTEST_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: HICON m_hIcon; // Generated message map functions virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() public: // 服务器IP地址 CString m_Address; // 服务器端口号 int m_Port; // 消息接收显示控件 CListBox m_MsgR; afx_msg void OnBnClickedBtClear(); afx_msg void OnBnClickedOk(); // 用户输入的即将发送的内容 CString m_MsgS; afx_msg void OnBnClickedBtConnect(); afx_msg void OnTimer(UINT_PTR nIDEvent); // 连接服务器次数 int m_nTryTimes; ClientSocket m_ClientSocket; afx_msg void OnBnClickedBtSend(); afx_msg void OnBnClickedBtClose(); };
其实现代码如下:
// SocketTestDlg.cpp : implementation file // #include "stdafx.h" #include "SocketTest.h" #include "SocketTestDlg.h" #include "afxdialogex.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CAboutDlg dialog used for App About class CAboutDlg : public CDialogEx { public: CAboutDlg(); // Dialog Data enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) END_MESSAGE_MAP() // CSocketTestDlg dialog CSocketTestDlg::CSocketTestDlg(CWnd* pParent /*=NULL*/) : CDialogEx(CSocketTestDlg::IDD, pParent) , m_Address(_T("127.0.0.1")) , m_Port(0) , m_MsgS(_T("")) , m_nTryTimes(0) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CSocketTestDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Text(pDX, IDC_ET_IPADDRESS, m_Address); DDX_Text(pDX, IDC_ET_PORT, m_Port); DDX_Control(pDX, IDC_LIST_R, m_MsgR); DDX_Text(pDX, IDC_ET_SEND, m_MsgS); } BEGIN_MESSAGE_MAP(CSocketTestDlg, CDialogEx) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BT_CLEAR, &CSocketTestDlg::OnBnClickedBtClear) ON_BN_CLICKED(IDOK, &CSocketTestDlg::OnBnClickedOk) ON_BN_CLICKED(IDC_BT_CONNECT, &CSocketTestDlg::OnBnClickedBtConnect) ON_WM_TIMER() ON_BN_CLICKED(IDC_BT_SEND, &CSocketTestDlg::OnBnClickedBtSend) ON_BN_CLICKED(IDC_BT_CLOSE, &CSocketTestDlg::OnBnClickedBtClose) END_MESSAGE_MAP() // CSocketTestDlg message handlers BOOL CSocketTestDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { BOOL bNameValid; CString strAboutMenu; bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); ASSERT(bNameValid); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application'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 return TRUE; // return TRUE unless you set the focus to a control } void CSocketTestDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialogEx::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CSocketTestDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialogEx::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR CSocketTestDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CSocketTestDlg::OnBnClickedBtClear() { // TODO: Add your control notification handler code here m_MsgR.ResetContent(); } void CSocketTestDlg::OnBnClickedOk() { // TODO: Add your control notification handler code here /*CDialogEx::OnOK();*/ UpdateData(TRUE); if(m_MsgS.IsEmpty()) { AfxMessageBox(_T("please type the message you want to send!")); return; } } void CSocketTestDlg::OnBnClickedBtConnect() { // TODO: Add your control notification handler code here //如果当前已经与服务器建立了连接,则直接返回 if(m_ClientSocket.m_bConnected) { AfxMessageBox(_T("当前已经与服务器建立连接")); return; } UpdateData(TRUE); if(m_Address.IsEmpty()) { AfxMessageBox(_T("服务器的IP地址不能为空!")); return; } if(m_Port <=1024) { AfxMessageBox(_T("服务器的端口设置非法!")); return; } //使Connect按键失能 GetDlgItem(IDC_BT_CONNECT)->EnableWindow(FALSE); //启动连接定时器,每1秒中尝试一次连接 SetTimer(1,1000,NULL); } void CSocketTestDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: Add your message handler code here and/or call default if(m_ClientSocket.m_hSocket ==INVALID_SOCKET) { BOOL bFlag =m_ClientSocket.Create(0,SOCK_STREAM,FD_CONNECT); //创建套接字 if(!bFlag) { AfxMessageBox(_T("Socket创建失败!")); m_ClientSocket.Close(); PostQuitMessage(0);//退出 return; } } m_ClientSocket.Connect(m_Address,m_Port); //连接服务器 if(m_nTryTimes >=10) { KillTimer(1); AfxMessageBox(_T("连接失败!")); GetDlgItem(IDC_BT_CONNECT)->EnableWindow(TRUE); return; } else if(m_ClientSocket.m_bConnected) { KillTimer(1); GetDlgItem(IDC_BT_CONNECT)->EnableWindow(TRUE); return; } CString strTextOut =_T("尝试连接服务器第"); m_nTryTimes ++; CString str; str.Format(_T("%d"),m_nTryTimes); strTextOut +=str; strTextOut +=_T("次..."); m_MsgR.InsertString(0,strTextOut); CDialogEx::OnTimer(nIDEvent); } void CSocketTestDlg::OnBnClickedBtSend() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(m_ClientSocket.m_bConnected) { //将用户输入的数据从CString转化为char *字符串,即Unicode-->ANSI,并保存到m_ClientSocket.m_szBuffer中 int len =WideCharToMultiByte(CP_ACP,0,m_MsgS,-1,NULL,0,NULL,NULL); WideCharToMultiByte(CP_ACP,0,m_MsgS,-1,m_ClientSocket.m_szBuffer,len,NULL,NULL ); m_ClientSocket.m_nLength =strlen(m_ClientSocket.m_szBuffer); m_ClientSocket.AsyncSelect(FD_WRITE);//触发写事件 m_MsgS =_T(""); UpdateData(FALSE); } } void CSocketTestDlg::OnBnClickedBtClose() { // TODO: Add your control notification handler code here m_ClientSocket.ShutDown(); EndDialog(0); }
OK,完!
相关推荐
基于CAsyncSocket类的网络编程-客户端代码
CAsyncSocket类及其成员在网络编程中的使用方法讲解
基于CAsyncSocket的网络编程
学习网络编程CAsyncSocket类.ppt
使用MFC快速实现网络编程 CAsyncSocket
使用MFC提供的网络编程CAsyncSocket类快速实现网络编程,其中包含服务器端CA_Server和客户端CA_Client;以Echo例程来实现CAsyncSocket类的网络编程
MFC网络编程之CAsyncSocket,里面详细的讲解了CAsyncSocket类的各个函数,及使用注意事项
本文主要讲解以下内容 (1)CAsyncSocket类... 使用这个类进行网络编程,就要求程序员对网络通信和Socket编程模式有相当的了解,因为程序员 要自己编写程序处理阻塞、字节顺序以及Unicode与MBCS之间的转换等问题。
使用CAsyncSocket完成的客户端和服务端通讯示例程序源代码 更多资源请访问http://www.59186618.com
(2)熟练掌握 CAsyncSocket 类的编程模型及其使用方式。 (3)采用 C/S 模式,分为客户端程序和服务器端程序。由于服务器只能支持一个客户,实际是一个点对点通信的程序。客户端程序和服务器程序通过网络交换聊天的...
这是仿照《Visual C++ 网络通信编程实用案例精选》书中的聊天室开发的 CAsyncSocket 聊天室,原来的程序是使用 WSAAsyncSelect 和 CSocket 开发的,这个程序尝试使用 CAsyncSocket 实现了相同的功能。代码已使用 ...
1.2 三类网络编程 10 1.2.1 基于TCP/IP协议栈的网络编程 10 1.2.2 基于WWW应用的网络编程 10 1.2.3 基于.NET框架的Web Services网络编程 10 1.3 客户机/服务器交互模式 13 1.3.1 网络应用软件的地位和...
运用MFC CAsyncSocket类设计实现一个简单的C/S模式的点对点通信程序。客户机和服务器程序通过网络交换字符串信息,并在各自窗口的列表中显示已发送的消息内容和接收到的消息内容
这个资料是我至今舍不得删除的VC++的网络编程总结。非常详细,有条理,而且对socket csocket CAsyncSocket 等的概念,原理分析得非常好,看了你就知道。 1.套接字编程原理 1.1 Client/server通信模型 1.2 ...
高级网络编程6.1 简单MFC网络编程6.1.1 网络聊天应用实例6.1.2 MFC基本框架与接口6.1.3 网络应用实例的实现6.2 基于MFC Socket类编程6.2.1 CAsyncSocket类和CSocket类6.2.2 网络应用实例功能介绍6.2.3 网络应用实例...
网络概念通讯入门及c++网络入门,MFC CAsyncSocket介绍
SocketAPI,CAsyncSocket,CSocket内幕及其用法 MFC下CSocket编程详解 异步套接字基础 CAsyncSocket及CSocket MFC疑难注解 利用MFC的Csocket类实现网络通信 CASyncSocket类和CSocket类编程
高级网络编程6.1 简单MFC网络编程6.1.1 网络聊天应用实例6.1.2 MFC基本框架与接口6.1.3 网络应用实例的实现6.2 基于MFC Socket类编程6.2.1 CAsyncSocket类和CSocket类6.2.2 网络应用实例功能介绍6.2.3 网络应用实例...