Click here to Skip to main content
15,886,518 members
Articles / Desktop Programming / MFC

STL WebServer

Rate me:
Please Sign up or sign in to vote.
4.89/5 (5 votes)
8 May 2000 90K   2.5K   47  
A set of classes written in STL that implement a web server
#if !defined(TransferStatus_H)
#define TransferStatus_H



/////////////////////////////////////////////////////////////////////////////////////
// TransferStatus
//
// Purpose:	used to keep track of a transfer

class TransferStatus
{
	long			_blockSize;		// no to send at one time
	long			_noToSend;		// number of bytes left to send 
	long			_noSent;		// number of bytes sent in response

public:

	TransferStatus () :
		_blockSize(0),
		_noToSend(0),
		_noSent(0)
	{}

	// setup status
	void reset ()
	{
		_noToSend = 0;
		_noSent = 0;
	}

	void begin ( long noToSend )
	{
		_blockSize = noToSend;
		_noToSend = noToSend;
		_noSent = 0;
	}

	void setSizeToSend ( long noToSend )
	{
		begin(noToSend);
	}

	// get/set block size
	long getBlockSize ()
	{
		return _blockSize;
	}

	void setBlockSize ( long set )
	{
		_blockSize = set;
	}

	// status methods
	long size()
	{
		return _noToSend;
	}

	long getNoToSend ()
	{
		return _noToSend;
	}

	long getNoSent ()
	{
		return _noSent;
	}

	void incNoSent ( long inc )
	{
		// if not valid stop
		if ( inc <= 0 )
			return;

		// update no sent
		_noSent += inc;
		if ( _noSent > size() )
			_noSent = size();
	}

	void decNoToSend ( long dec )
	{
		// if not valid stop
		if ( dec <= 0 )
			return;

		// update no to send
		_noToSend -= dec;
		if ( _noToSend < 0 )
			_noToSend = 0;
	}

	bool finished ()
	{
		// if all sent show it
		if ( _noSent == _noToSend )
			return true;
		else
			return false;
	}




};

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions