wzdsock.h
来自「MFC扩展编程实例」· C头文件 代码 · 共 91 行
H
91 行
// WzdSock.h: interface for the CWzdServer and CWzdClient class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_WZDSOCK_H__81CE0F20_8C16_11D2_A18D_99620BDF6820__INCLUDED_)
#define AFX_WZDSOCK_H__81CE0F20_8C16_11D2_A18D_99620BDF6820__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afxsock.h>
#include <afxtempl.h>
#include "WzdQue.h"
#define WM_NEW_MESSAGE WM_USER+1
#define WM_DONE_MESSAGE WM_USER+2
//////////////////////////////////////////////////////////////////////
// Thread data
//////////////////////////////////////////////////////////////////////
typedef struct t_SENDDATA
{
CSocket *pSocket;
LPSTR lpBuf;
int len;
} SENDDATA;
typedef CMap<int,int,CSocket *,CSocket *> SOCKMAP;
typedef struct t_RECVDATA
{
CSocket *pSocket;
int hdrSz;
int bodyPos;
CWzdQueue *pQueue;
CWnd *pWnd;
UINT id;
} RECVDATA;
//////////////////////////////////////////////////////////////////////
// CWzdServer
//////////////////////////////////////////////////////////////////////
class CWzdServer : public CSocket
{
public:
CWzdServer(){};
virtual ~CWzdServer();
BOOL Open(UINT nPort);
void CloseEx();
void SendEx(int id, LPSTR lpBuf, int len);
void ListenEx(int hdrSz, int bodyPos, CWzdQueue *pQueue, CWnd *pWnd, UINT id);
// Overrides
virtual void OnAccept ( int nErrorCode );
private:
int m_id;
SENDDATA m_SendData;
RECVDATA m_RecvData;
SOCKMAP m_mapSockets;
};
//////////////////////////////////////////////////////////////////////
// CWzdClient
//////////////////////////////////////////////////////////////////////
class CWzdClient : public CSocket
{
public:
CWzdClient() {};
virtual ~CWzdClient() {};
BOOL Open(LPCTSTR lpszHostAddress, UINT nHostPort);
void SendEx(LPSTR lpBuf, int len);
void ListenEx(int hdrSz, int bodyPos, CWzdQueue *pQueue, CWnd *pWnd, UINT id);
private:
SENDDATA m_SendData;
RECVDATA m_RecvData;
};
//////////////////////////////////////////////////////////////////////
// Threads
//////////////////////////////////////////////////////////////////////
UINT SendThread( LPVOID pParam );
UINT RecvThread( LPVOID pParam );
#endif // !defined(AFX_WZDSOCK_H__81CE0F20_8C16_11D2_A18D_99620BDF6820__INCLUDED_)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?