⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 socketresource.h

📁 1、自己编写的遵循SGIP1.1的短信网关模拟程序。仅供测试、学习。 2、该程序只实现了SGIP1.1协议的一部分。
💻 H
字号:
/////////////////////////////////////////////////////////////////////////
// Note: this class is used to manage the connection resource to 
//       the short message gate, both for server connection resource
//       and client connection resource
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// SocketResource.h: interface for the CSocketResource class.
////Author: lijinhu
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SOCKETRESOURCE_H__62DDEB1D_8AA1_4D53_8C3E_232A66AF5B4E__INCLUDED_)
#define AFX_SOCKETRESOURCE_H__62DDEB1D_8AA1_4D53_8C3E_232A66AF5B4E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Constants.h"
#include "afxmt.h"
#include "SgipServerSocket.h"
#include "SgipClientSocket.h"
#include "SgipListenSocket.h"

//class CSgipServiceDemoDlg;
typedef struct tagSERVER_CONNECTION
{
	int iStatus;//0:free;1:used
	int iSocketNo;//
	CSgipServerSocket *pServerSocket;
}SERVER_CONNECTION;

typedef struct tagCLIENT_CONNECTION
{
	int iSocketNo;//
	CSgipClientSocket *pClientSocket;
}CLIENT_CONNECTION;


class CSocketResource  
{
//attr
	friend class CSgipServerSocket;
	friend class CSgipClientSocket;
	friend class CSgipListenSocket;
//attr
protected:
//	CSgipServiceDemoDlg *m_pMainWnd;
	CCriticalSection m_CritSectionClient;
	CCriticalSection m_CritSectionServer;
	CSgipListenSocket m_ListenSocket;
	//CSgipClientSocket m_ClientSocket[CR_MAX_CLIENT_NUM];
	CLIENT_CONNECTION m_ClientSocket[CR_MAX_CLIENT_NUM];
	SERVER_CONNECTION m_ServerSocket[CR_MAX_SERVER_NUM];
	t_INIT_DEF m_ini_def;

	BOOL m_bInited;
//function
public:
//	void SetMainWnd(CSgipServiceDemoDlg *pMainWnd);
	unsigned long SetSgipSerialTime();
	int SubmitOneMsg(CString strContent, CString strDestPhoneNum, CString strFeePhoneNo, unsigned long ulSgipSerialNo, int iReportFlag,int iMsgCoding, BOOL bWaitResp = TRUE);
	int DeliverOneMsg(CString strUserNum, CString strContent, unsigned long ulSgipSerialNo, int iMsgCoding, BOOL bWaitResp = TRUE);
	void Check();
	BOOL SetServerSocketStatus(int iSocketNo,int iStatus);
	BOOL SetChannelSubmitStatus(unsigned long ulSgipSerial,int iChannelNo,int iSubmitStatus);
	BOOL SetChannelStatus(int iSocketNo,int iChannelNo, int iStatus);
	BOOL FreeChannel(int iSocketNo,int iChannelNo,unsigned long ulSgipSerialNo);
	
	BOOL InitSocket(t_INIT_DEF ini_def);
	BOOL ExitSocket();
	BOOL ReInitSocket();
	CSocketResource();
	virtual ~CSocketResource();
protected:
	BOOL InitServerSocket();
	BOOL InitClientSocket();
	BOOL CloseClientSocket();
	BOOL CloseServerSocket();
	int GetServerSocket(int *piSocketNo,CSgipServerSocket ** ppServerSocket);
	int GetClientSocket(int *piSocketNo , CSgipClientSocket **ppClientSocket , int *piChannelNo ,unsigned long ulSgipSerialNo,int iCmdBufNo);
	int ConSocket(int iSocketNo);
//	CSgipClientSocket* GetClientSocket(int iSocketNo);
};

#endif // !defined(AFX_SOCKETRESOURCE_H__62DDEB1D_8AA1_4D53_8C3E_232A66AF5B4E__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -