/*
 *  mSock: Non-blocking client and server classes.
 */

#include <string>

struct mSock_data_members;
typedef unsigned int mSockClient;

//=========================================================

class mSock {
public:
	mSock(const char* hostname, unsigned short port);
#ifndef MSOCK_DISABLE_SERVER
	mSock(mSockClient msc);
#endif
	~mSock();

	bool isValid();
	void doEvents();
	void close();

	void put(const char* data);
	void put(const char* data, int count);
	std::string get();

private:
	mSock_data_members* d;
	void check_err();
};

//=========================================================

#ifndef MSOCK_DISABLE_SERVER
class mSockServer {
public:
	mSockServer(unsigned short port);
	~mSockServer();

	bool isValid();
	mSockClient newConn(); // -1 on no new client

private:
	mSock_data_members* d;
	void check_err();
};
#endif

