This repository has been archived by the owner on Aug 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCClientTCP.h
56 lines (41 loc) · 2.22 KB
/
CClientTCP.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef ____CLIENT_TCP____
#define ____CLIENT_TCP____
#if defined (WIN32)
#include <winsock2.h>
#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
#include <string>
#include "CColor.h"
class CClientTCP
{
private :
SOCKET mSock; // socket
SOCKADDR_IN mSin; // structure d'information pour la socket
int mError; // erreur de connection de la socket
void connectClient(); // se connecte au serveur ( connect est pris )
void sendQuery( std::string pQuery ); // envoie le segment tcp contenant la chaine de caractere ( string ) (send est déjà pris)
public :
// CClientTCP();
CClientTCP( std::string pIp, unsigned short pPort );
~CClientTCP();
int getLastError(); // recupere l'erreur de connection
void connectClient( std::string pIp, unsigned short pPort ); // se connecte au serveur
void disconnect(); // se deconnecte du serveur
void clear(); // efface l'ecran
void drawPoint( int pX, int pY, CColor pColor ); // affiche un point
void drawSegment( int pX1, int pY1, int pX2, int pY2, CColor pColor ); // affiche un segment
void drawCircle( int pX, int pY, int pRadius, CColor pColor, bool pFull = false ); // affiche un cercle
void drawRectangle( int pX1, int pY1, int pX2, int pY2, CColor pColor, bool pFull = false ); // affiche un rectangle
};
#endif