#ifndef SERVEUR_H_INCLUDED
#define SERVEUR_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 Serveur
{
public:
    Serveur(int port, int nbrClient);
    ~Serveur();

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


private:
    #ifdef WIN32
    WSADATA m_WSAData;
    #endif

    Sock m_sock;
    Sock *m_csock;

    int m_port;
    int m_erreur;
    const int m_nbrClient;
};

#endif // SERVEUR_H_INCLUDED