///////////////////////////////////////////////////////////////////////////////
/// @file deTCPConnection.hpp
///
/// @brief 
///
/// @author trajar
///
/// This file is the intellectual property of Novus Delta, LLC.. Usage of the
/// contents of this file is subject to the Destiny3D Member License which
/// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
///
/// This file is distributed "AS IS" without warranty of any kind.  Novus
/// Delta, LLC. does not guarantee the fitness of the contents of this file
/// for any particular purpose.
///
/// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
///
/// <hr>
///                                 Change History
/// <hr>
///
/// @date Jun 2002
/// @author trajar
/// @remarks Creation
///
///////////////////////////////////////////////////////////////////////////////

#ifndef	_DETCPCONNECTION_HPP
#define _DETCPCONNECTION_HPP

#ifdef		_DENET_HPP
 #include	"deNet.hpp"
#endif

#ifdef		_DENETWINSOCK_HPP
 #include	"deNetWinsock.hpp"
#endif

#ifndef		_DECONNECTION_HPP
 #include	"deConnection.hpp"
#endif

#include	<VECTOR>
typedef		std::vector< deTCPOVERLAPPED* > aPendingTCPSends;

typedef class DENET_API deTCPConnection : public deConnection
{
	friend class deTCPConnectionProvider;

public:
	deTCPConnection(void);
	virtual ~deTCPConnection(void);

	struct TCPConnectionInfo
	{	
		GROUP			gGroup;
		WSAEVENT		hEvent;
		SOCKET			hSocket;
		SOCKADDR_IN		address;
	};

	const	TCPConnectionInfo&	GetConnectionInfo(void)		const	{ return m_ConnectionInfo; }

	void				ReleasePendingTCPSend( deTCPOVERLAPPED * pOver );

protected:

	virtual eNetError	OnAttemptReset( DWORD dwFlags = NULL );
	virtual eNetError	OnBindAsServer( DWORD dwFlags = NULL );
	virtual eNetError	OnRecieve( DWORD dwFlags = NULL );
	virtual eNetError	OnConnectTo( deNetAddress * pAddress );
	virtual eNetError	OnSend( WORD pNetMsgID, const void * pBuff, DWORD iSize, DWORD dwFlags = NULL );	
	virtual eNetError	OnDisconnect( DWORD dwFlags = NULL );
	
private:

	aPendingTCPSends	m_aPendingTCPSends;
	TCPConnectionInfo	m_ConnectionInfo;

} deTCPConnection, *pdeTCPConnection;

#endif