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

📄 blocksock.h

📁 本源码为移动公司话费查询中间件TUXEDO使用的实例
💻 H
字号:
/********************************************
* file name:   blocksock.h
* date:        2001.07.06
*
********************************************/
// needs winsock.h in the precompiled headers
#if !defined(AFX_BLOCKSOCK_H_LINYOUHAI)
#define AFX_BLOCKSOCK_H_LINYOUHAI

#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#endif //_WIN32

#include <assert.h>

//#define NULL 0

#include "SHPP.h"
//#include <winsock2.h>

#define	TIMEOUT      10

//typedef const struct sockaddr* LPCSOCKADDR;
typedef struct sockaddr* LPCSOCKADDR;

#ifndef _WIN32
typedef int SOCKET;
#endif

#ifdef _DEBUG
class CSocketException : public CErrorMessage
{
public:
// Constructor
	CSocketException(char* inMes = NULL)
		: CErrorMessage(inMes,KN_SocketError) {}

//	~CSocketException() {}
};
#endif //#ifdef _DEBUG
/******************class CKNSocket***************************/
// member functions truly block and must not be used in UI threads
// use this class as an alternative to the MFC CSocket class
class CKNSocket
{
public:
	SOCKET m_hSocket;
	CKNSocket() { m_hSocket = NULL; }
	void Cleanup();
	void Create(int nType = SOCK_STREAM);
	void Close();
	void Bind(LPCSOCKADDR psa);
	void Listen();
	int Connect(LPCSOCKADDR psa);
	int Accept(CKNSocket& s, LPCSOCKADDR psa);
	int Send(const char* pch, const int nSize, const int nSecs);
	int Write(const char* pch, const int nSize, const int nSecs);
	int Receive(char* pch, const int nSize, const int nUSecs);
	int SendDatagram(const char* pch, const int nSize, LPCSOCKADDR psa, 
		const int nSecs = 10 );
	int ReceiveDatagram(char* pch, const int nSize, LPCSOCKADDR psa, 
		const int nSecs = 10);
	void GetPeerAddr(LPCSOCKADDR psa);
	void GetSockAddr(LPCSOCKADDR psa);
	operator SOCKET()
		{ return m_hSocket; }
};

#endif //define(AFX_BLOCKSOCK_H_LINYOUHAI)

⌨️ 快捷键说明

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