#if !defined(AFX_CLIENTSOCKET_H__B810CD96_2A54_41F9_AEF2_5EBE271ECD62__INCLUDED_)
#define AFX_CLIENTSOCKET_H__B810CD96_2A54_41F9_AEF2_5EBE271ECD62__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ClientSocket.h : header file
//



/////////////////////////////////////////////////////////////////////////////
// CClientSocket command target
#include "YBuffer.h"

#define WM_SOCKET_CONNECTED				WM_USER + 501
#define WM_SOCKET_DISCONNECTED			WM_USER + 502
#define WM_SOCKET_RECEIVED_DATA			WM_USER + 503

#define BUFFERING_SIZE 2048

#define MYSOCK_NOERROR ( 0 )
#define MYSOCK_WINDOWS_ERROR ( -1 )
#define MYSOCK_WINSOCK_ERROR ( -2 )
#define MYSOCK_PROGRAMMING_ERROR ( 3 )
#define MYSOCK_TRANSACTION_ERROR ( 4 )
#define MYSOCK_NORESPONSE_ERROR ( -5 )
#define MYSOCK_BLOCKING_START ( -6 )
#define	DISCONNECTTING		1
#define	DISCONNECTED	0  

#define	CLOSING		2
#define	CLOSED		0  

#define	CONNECTTING	3
#define	CONNECTED	4

#define	WRITING	5
#define	WROTE 6

class CClientSocket : public CAsyncSocket
{
// Attributes
public:
	HWND		m_pHwnd;
	YBuffer		m_ReadBuffer; 
	YBuffer		m_WriteBuffer; 

	int			m_nCurrState;
// Operations
public:
	CClientSocket();
	virtual ~CClientSocket();

	int SendData( KPacket* pData );
	void SetWnd(HWND hwnd);

	void SendWouldBlockData();

	void Linger();

	int Connect ( CString strAddr, int PortNo );
	void Disconnect();

	BOOL IsConnected();

// Overrides
public:
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CClientSocket)
	public:
	virtual void OnClose(int nErrorCode);
	virtual void OnReceive(int nErrorCode);
	virtual void OnConnect(int nErrorCode);
	virtual void OnSend(int nErrorCode);
	//}}AFX_VIRTUAL

	// Generated message map functions
	//{{AFX_MSG(CClientSocket)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG

// Implementation
protected:
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CLIENTSOCKET_H__B810CD96_2A54_41F9_AEF2_5EBE271ECD62__INCLUDED_)
