//---------------------------------------------------------------------------

#ifndef Form_MainH
#define Form_MainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include "IdBaseComponent.hpp"
#include "IdComponent.hpp"
#include "IdContext.hpp"
#include "IdCustomTCPServer.hpp"
#include "IdTCPServer.hpp"
#include "IdTCPClient.hpp"
#include "IdTCPConnection.hpp"
#include <ExtCtrls.hpp>
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------
class TWin_Main : public TForm
{
__published:	// IDE-managed Components
	TStatusBar *StatusBar;
	TIdTCPServer *TCPServer;
	void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
	void __fastcall FormCreate(TObject *Sender);
	void __fastcall TCPServerExecute(TIdContext *AContext);
	void __fastcall TCPServerConnect(TIdContext *AContext);
	void __fastcall TCPServerDisconnect(TIdContext *AContext);
private:	// User declarations
public:		// User declarations
	TCriticalSection	*Cs;
    TIdContext 			*lpContext[100];
    DWORD				SpeedTimer;
    int					UserCount, SendSize, RecvSize;

	__fastcall TWin_Main(TComponent* Owner);

};
//---------------------------------------------------------------------------
extern PACKAGE TWin_Main *Win_Main;

//---------------------------------------------------------------------------
class TConsole
{
public:
	TConsole()
	{
		AllocConsole();
		freopen("CONIN$", "rb", stdin);
		freopen("CONOUT$", "wb", stdout);
		freopen("CONOUT$", "wb", stderr);
		setbuf(stderr, 0);
	}
	~TConsole()
	{
		fclose(stdin);
		fclose(stdout);
		fclose(stderr);

		FreeConsole();
	}
};

//---------------------------------------------------------------------------
static  TConsole clConsole;

#endif
