www.pudn.com > 221315556.rar > Socket.h


// MirSocket.h: interface for the CMirSocket class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_MIRSOCKET_H__4D0584A6_2541_4CD2_AADB_A6BBC39D6032__INCLUDED_) 
#define AFX_MIRSOCKET_H__4D0584A6_2541_4CD2_AADB_A6BBC39D6032__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
#include  
#include "stdserver.h" 
typedef struct _connectioninfo_ 
{ 
	SOCKET	Socket; 
	CHAR	IpAddress[20]; 
	UINT	Port; 
}CONNECTION,*PCONNECTION; 
 
typedef struct _serverinitinfo_ 
{ 
	CHAR	WanIp[20];		//	广域网绑定IP 
	CHAR	LanIp[20];		//	局域网绑定IP 
	UINT	WanPort;		//	广域网监听端口 
	UINT	LanPort;		//	局域网监听端口 
	DWORD	dwParam[16];	//	参数表 
}SERVERINITINFO, *PSERVERINITINFO; 
class CSocket   
{ 
public: 
	int Send( SOCKET s, void * buf, int len ); 
	int Recv( SOCKET s, void * buf, int len ); 
	CSocket(); 
	virtual ~CSocket(); 
	int		SetNoBlock( SOCKET s ); 
	int SetBlock( SOCKET s ); 
	void	CloseConnection( SOCKET s ); 
	SOCKET	OpenConnection( const char * ip, const UINT port ); 
	SOCKET	Listen( UINT port, int maxqueue ); 
	static BOOL	NetCleanup(); 
	static BOOL	NetStartup(); 
	// 网络初始化 
	static BOOL NetStartup(int ver1, int ver2); 
	BOOL Accept(SOCKET sListen, SOCKET & sAccept); 
	BOOL Accept(SOCKET sListen, SOCKET& sAccept, char* pszIpAddr, UINT& usPort); 
	BOOL OpenConnection(const char * IpAddress , const UINT Port, PCONNECTION pConnection); 
	BOOL OpenConnection(const char * IpAddress , const UINT Port, PCONNECTION pConnection, int nSeconds); 
	BOOL OpenConnection(const char * IpAddress , const UINT Port,const char * szProxyIpAddress , const UINT nProxyPort,const CHAR*szProxyUserName, const CHAR *szProxyPassword, UINT	nProxyType,  PCONNECTION pConnection ); 
	BOOL Listen(UINT Port, int MaxQueue, PCONNECTION pConnection); 
	BOOL Accept(SOCKET sListen, PCONNECTION pConnection); 
	BOOL CloseConnection(PCONNECTION pConnection); 
	BOOL SetNoBlock(PCONNECTION pConnection); 
	BOOL UDPBind(char* szIpAddress, UINT uPort, PCONNECTION pConnection); 
}; 
 
#endif // !defined(AFX_MIRSOCKET_H__4D0584A6_2541_4CD2_AADB_A6BBC39D6032__INCLUDED_)