#ifndef NET_H
#define NET_H

#if defined __GNUC__ && (__GNUC__ >= 3)
#include <ext/hash_map>
#else
#include <hash_map>
#endif

class Queue
{
	public:
		Queue(){sendpos = 0; receivepos = 0;}
		char send[1024];
		char receive[1024];
		int sendpos;
		int receivepos;
};

class Net
{
	public:
		Net();
		~Net();

		enum SpecialOpcodes
		{
			begin = -1001,
			end = -1002,
			flush = -1003,
			channel = -1004,
			input = -1005
		};

		Net &operator<<(SpecialOpcodes value);
		Net &operator<<(int value);
		Net &operator<<(const char* value);

		Net &operator>>(int* value);
		Net &operator>>(char** value);

		int empty();

	private:
		void forceinput();

		int m_fd;
		int waitforchannel;
		int buffered;
#if defined __GNUC__ && (__GNUC__ >= 3)
		__gnu_cxx::hash_map<int, Queue> queues;
#else
		hash_map<int, Queue> queues;
#endif
};

#endif

