123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #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
|