/* * * * * * * * * * * * * * * * 
 * 	 ______     __  __     ______     __  __     ______     ______     __  __    
 *	/\  __ \   /\ \/\ \   /\  == \   /\ \_\ \   /\  __ \   /\  ___\   /\ \/ /    
 *	\ \ \/\ \  \ \ \_\ \  \ \  __<   \ \  __ \  \ \  __ \  \ \ \____  \ \  _"-.  
 *	 \ \_____\  \ \_____\  \ \_____\  \ \_\ \_\  \ \_\ \_\  \ \_____\  \ \_\ \_\ 
 *	  \/_____/   \/_____/   \/_____/   \/_/\/_/   \/_/\/_/   \/_____/   \/_/\/_/ 
 *
 *  - Version : 3L
 *  - By Oubliette
 * * * * * * * * * * * * * * * */

#ifndef _SOCK

#define _SOCK

#define WIN32_LEAN_AND_MEAN

#include "oubhack.h"
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
#include <stdio.h>


// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")

class ISocket {

private :

	SOCKET m_Socket;
	bool m_bIsValid;

public :

	// Constructors
	ISocket( SOCKET );
	ISocket( const char*, const char* ccPort = "60152" );
	
	// Send 

	void				WriteInt( int );
	void				WriteString( const char* );
	void				WriteLong( long );
	void				WriteFloat( float );
	void				WriteDouble( double );
	void				WriteShort( short );
	void				WriteI64( int64_t );
	void				WriteUI64( unsigned long long );
	void				WriteBool( bool );
	void				WriteChar( char );
	void				WriteByte( byte );
	void				WriteBytes( byte[], int );

	// Read

	int					ReadInt( );
	std::string			ReadString( );
	long				ReadLong( );
	float				ReadFloat( );
	double				ReadDouble( );
	short				ReadShort( );
	long long			ReadI64( );
	unsigned long long	ReadUI64( );
	bool				ReadBool( );
	char				ReadChar( );
	byte				ReadByte( );
	byte*				ReadBytes( int ); 
	const char*			ReadBytes2String( int, int* ); 

	// Misc'

	void Shutdown();
	bool IsValid();

};

#endif