www.pudn.com > HttpServerusingWinSocket.rar > MyBlockSocket.h


// MyBlockSocket.h: interface for the CMyBlockSocket class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_MYBLOCKSOCKET_H__000480DF_A4E6_4BF1_B278_30D770D7522C__INCLUDED_) 
#define AFX_MYBLOCKSOCKET_H__000480DF_A4E6_4BF1_B278_30D770D7522C__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
#include "SocketAddress.h" 
 
typedef const struct sockaddr* LPCSOCKADDR; 
 
class CMyBlockSocket : public CObject   
{ 
	DECLARE_DYNAMIC(CMyBlockSocket) 
public: 
	SOCKET m_hSocket; 
	CMyBlockSocket(); 
	void Cleanup(); 
	void Create(int nType=SOCK_STREAM); 
	void Close(); 
	void Bind(LPCSOCKADDR psa); 
	void Listen(); 
	void Connect(LPCSOCKADDR psa); 
	BOOL Accept(CMyBlockSocket &s,LPSOCKADDR 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 nSecs); 
	int SendDatagram(char *pch,const int nSize,LPSOCKADDR psa,const int nSecs); 
	int ReceiveDatagram(char *pch,const int nSize,LPSOCKADDR psa,const int nSecs); 
	void GetPeerAddr(LPSOCKADDR psa); 
	void GetSockAddr(LPSOCKADDR psa); 
	static CSocketAddress GetHostByName(const char *pchName,const USHORT ushPort=0); 
	static const char * GetHostByAddr(LPCSOCKADDR psa); 
	operator SOCKET(){ 
		return m_hSocket; 
	} 
	virtual ~CMyBlockSocket(); 
 
}; 
 
#endif // !defined(AFX_MYBLOCKSOCKET_H__000480DF_A4E6_4BF1_B278_30D770D7522C__INCLUDED_)