External Exam Download Resources Web Applications Games Recycle Bin

TcpClient.h

---------------------------------
TcpConsole Class Declaration File
---------------------------------*/

#ifndef _TCPCLIENT_H
#define _TCPCLIENT_H

#include "stdafx.h"

using namespace System;
using namespace System::IO;  //for StreamWriter and StreamReader Classes, etc.
using namespace System::Net;  //for protocol-related classes.
using namespace System::Net::Sockets;  //for managed implementation of Winsock interface.

/***************************************************************************************
TcpConsole Class: used to manage client console for interaction with reservation server.
****************************************************************************************/
ref class TcpConsole
{
private:
	//variables:
	bool failedFlag;
	TcpClient^ server; //Provides client connection for reservation service, and enables stream communication with this connection.
	bool expecting_unknown_length_answer;
	StreamReader^ reader; //Created from Networkstream object to handle incoming stream
	String^ write_buffer;
	String^ read_buffer;
	//functions:
	void read_unknown_length();
	
public:
	//constructor:
	TcpConsole();
	//destructor:
	~TcpConsole();
	//variables:
	StreamWriter^ writer; //as StreamReader (above) but to handle outgoing stream
	//functions (see implementation file for description of each):
	bool connect();
	void read_block();
	void menu_options();
	void prepare_request(String ^);
	void send_request();
	void process_response();
};

#endif