您的位置:首页 > 编程语言

孙鑫 第十四课Socket编程之四 实例UdpServerDlg.h

2012-12-05 17:19 330 查看
////////////////////////////////////////////////////实例,对应上篇文章的图///////////////////////////////// ////////

// UdpServerDlg.h : header file
#if !defined(AFX_UDPSERVERDLG_H__5ED06106_0278_457E_9CBC_4D9D8224E5A1__INCLUDED_)
#define AFX_UDPSERVERDLG_H__5ED06106_0278_457E_9CBC_4D9D8224E5A1__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ThradParam.h"
#include "winsock2.h"
#pragma comment(lib, "ws2_32.lib")

#define MAX_NUMBER_INFO 30//接受区域显示的信息最大条数
#define WM_UPDATEDATA (WM_USER + 1) //刷新接受区域消息

/////////////////////////////////////////////////////////////////////////////
// CUdpServerDlg dialog
class CUdpServerDlg : public CDialog
{
// Construction
public:
CUdpServerDlg(CWnd* pParent = NULL);// standard constructor

// Dialog Data
//{{AFX_DATA(CUdpServerDlg)
enum { IDD = IDD_UDPSERVER_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUdpServerDlg)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX);// DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
HICON m_hIcon;
HICON hIcon;

// Generated message map functions
//{{AFX_MSG(CUdpServerDlg)
virtual BOOL OnInitDialog(); //窗口初始化
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint(); //窗口重绘
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnBtnSend(); //发送 按钮
afx_msg void OnBtnSet(); //设置本机 / 对方地址 按钮
afx_msg void OnTimer(UINT nIDEvent); //定时器 改变窗口图标
//}}AFX_MSG
afx_msg void Update(WPARAM wParam, LPARAM lParam); //更新UI消息函数
DECLARE_MESSAGE_MAP()

public:
BOOL InitSocket(void); //初始化socket
static DWORD WINAPI RecvThread(LPVOID lpParam); //线程函数
void InitClientAddr(void); //初始化客户机地址

private:
SOCKET sockServer; //本socket
char* m_IP; //本机IP
int m_nPort; //端口
static SOCKADDR_IN m_addrclient; //对方IP端口信息
CString m_strUser; //当前用户名
int m_nCount; // 发送信息条数计数
CThreadParam m_threadParam; //CThreadParam类对象,用来给线程函数传递参数:窗口句柄,sockServer

};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_UDPSERVERDLG_H__5ED06106_0278_457E_9CBC_4D9D8224E5A1__INCLUDED_)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: