码迷,mamicode.com
首页 > 其他好文 > 详细

ClientSocket.h ClientSocket.cpp

时间:2018-10-10 14:11:36      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:std   EDA   成员函数   派生   span   receive   成员   nts   close   

ClientSocket.h

 1 #pragma once
 2 
 3 // CClientSocket 命令目标
 4 #include "ClientProDlg.h"
 5 #include "afxsock.h"
 6 
 7 
 8 class CClientProDlg;
 9 
10 class CClientSocket : public CSocket    //从CSocket类派生一个用于处理接收Socket的类
11 {
12 
13 public:
14     CClientSocket(CClientProDlg *pdlg);    //获得应用程序的指针
15     virtual ~CClientSocket();
16     CClientProDlg *m_pDlg;
17     virtual void OnReceive(int nErrorCode);
18     virtual void OnClose(int nErrorCode);
19 
20 };

ClientSocket.cpp 

 1 // ClientSocket.cpp : implementation file
 2 //
 3 #include "stdafx.h"
 4 #include "ClientSocket.h"
 5 #include "ClientProDlg.h"
 6 
 7 CClientSocket::CClientSocket(CClientProDlg *pdlg)
 8     : m_pDlg(pdlg)
 9 {
10 }
11 
12 CClientSocket::~CClientSocket()
13 {
14 }
15 
16 void CClientSocket::OnReceive(int nErrorCode) 
17 {
18     if(m_pDlg)
19     {
20         m_pDlg->ReceiveData(this);
21     }
22     CSocket::OnReceive(nErrorCode);
23 }
24 void CClientSocket::OnClose(int nErrorCode)
25 {
26     if(m_pDlg)
27     {        
28         m_pDlg->ClientDisConnect(this);
29     }
30     CSocket::OnClose(nErrorCode);
31 }
32 // CClientSocket 成员函数

ClientProDlg.h中添加

#include "ClientSocket.h"

void ReceiveData(CClientSocket* socket);

void ClientDisConnect(CClientSocket* socket);

CClientSocket *m_pSocket;

ClientSocket.h ClientSocket.cpp

标签:std   EDA   成员函数   派生   span   receive   成员   nts   close   

原文地址:https://www.cnblogs.com/qiwu1314/p/9765546.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!