#ifndef CLIENT_H_INCLUDED
#define CLIENT_H_INCLUDED

#ifdef WIN32
    #include <winsock2.h>
    typedef int socklen_t;
#elif defined (linux)
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <unistd.h>

    #define INVALID_SOCKET -1
    #define SOCKET_ERROR -1
    #define closesocket(s) close (s)

    typedef int SOCKET;
    typedef struct sockaddr_in SOCKADDR_IN;
    typedef struct sockaddr SOCKADDR;

#endif // WIN32
#include <iostream>

struct Sock
{
    SOCKADDR_IN sin;
    SOCKET sock;
    socklen_t recsize;
};

class Client
{
public:
    Client(std::string IP, int port);
    ~Client();

    bool rendreUtilisable();
    void envoyer(void* donnee, int tailleByte);
    void recevoir(void* donnee, int tailleByte);

private:
    #ifdef WIN32
    WSADATA m_WSAData;
    #endif

    Sock m_csock;

    std::string m_IP;
    int m_port;
    int m_erreur;
};

#endif // CLIENT_H_INCLUDED
