?? blocksock.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 + -