孙鑫 第十四课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_)
// 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_)
相关文章推荐
- python网络编程之TCP通信实例和socketserver框架使用例子
- 孙鑫VC视频教程笔记之第十四课“基于TCP和UDP的Socket编程”
- [python] 专题七.网络编程之套接字Socket、TCP和UDP通信实例
- Apache Mina 应用 TCP/UDP socket编程实例
- QT Socket编程--UDP Server
- 【转】UDP windows下socket编程实例
- python socket编程入门(编写server实例)+send 与sendall的区别与使用方法
- android开发socket编程之udp发送实例分析
- Socket通信编程基础__实例一__server端
- UDP windows下socket编程实例
- Python的Socket编程过程中实现UDP端口复用的实例分享
- UDP windows下socket编程实例
- 网路编程-UDP-DatagramSocket、DatagramPacket ||LocalServerSocket和LocalSocket
- 孙鑫 第十五/十六课之六 基于消息异步UDP套接字编程实例
- TCP/UDP网络编程入门教程之二:TCP Server端——socket与文件描述符
- 基于UDP协议的socket编程实例
- Java Socket编程实例(二)- UDP基本使用
- linux udp socket编程实例
- python网络编程之TCP通信实例和socketserver框架使用例子
- TCP/UDP网络编程入门教程之二:TCP Server端——socket与文件描述符