#ifndef Socket_class
#define Socket_class

#include <sys/fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string>
#include <cerrno>
#include <sstream>
#include <iostream>

#ifdef WIN32
	#define __USE_W32_SOCKETS 1
	#include <windows.h>
	#include <ws2tcpip.h>

	#define MSG_NOSIGNAL		0
	#define EAFNOSUPPORT            WSAEAFNOSUPPORT
#else
	#include <netdb.h>
	#include <sys/socket.h>
	#include <sys/param.h>
	#include <netinet/in.h>
	#include <arpa/inet.h>
	#include <netdb.h>
#endif


const int MAXHOSTNAME = 200;
const int MAXCONNECTIONS = 5;
const int MAXRECV = 2048;
// namespace DistributedPasswordGen {

	class Socket{
		public:
			Socket();
			virtual ~Socket();
			
			// Server initialization
			bool create();
			bool bind ( const int port );
			bool listen() const;
			bool accept ( Socket& );
			bool shutdown ();

			// Client initialization
			bool connect ( const std::string host, const int port );
			
			// Data Transimission
			bool send ( const std::string ) const;
			int recv ( std::string& ) const;


			bool send ( char[1] ) const;
			int recv ( char &c ) const;

// 			void set_non_blocking ( const bool );
			
			bool is_valid() const { return m_sock != -1; }
		
		public:
			std::string port;
			std::string host;
			int m_sock;
			sockaddr_in m_addr;
	
	
	};
// }

#endif
