#include <NetClient.h>
Fonctions membres publiques | |
| NetClient (unsigned int iCrypt=NET_T_NORMAL) | |
| ~NetClient () | |
| void | Start (const char *iIp, unsigned int iPort) |
| Démare le client. | |
| void | Stop () |
| Arrète le client. | |
| NetConnect * | GetConnect () |
| Retourne l'objet de connectoin. | |
| const char * | GetIp () |
| Retourne l'ip. | |
| unsigned int | GetPort () |
| Retourne le port. | |
| const char * | GetBuffer () |
| Retourne le buffer. | |
| unsigned int | GetBufferSize () |
| Retourne la taille buffer. | |
| void | BinSend (const char *pBuffer, unsigned int iSize) |
| Envoie des données binaire. | |
| void | Send (const char *pBuffer,...) |
| Envoie les données. | |
| void | Receive () |
| Recoit les données. | |
Définition à la ligne 22 du fichier NetClient.h.
|
|
Initialise avec des paramétres par defaut.
Définition à la ligne 13 du fichier NetClient.cpp. Références CATCH, THROW, et TRY. 00014 {
00015 conInfo = NULL;
00016 crypt = NET_T_NORMAL;
00017 TRY
00018
00019 #if USE_SSL == 1
00020 sslCTX = NULL;
00021 if(iCrypt == NET_T_SSL)
00022 {
00023 SSL_METHOD *sslMethode;
00024
00025 SSL_library_init();
00026 SSL_load_error_strings();
00027 sslMethode = SSLv23_server_method();
00028
00029 sslCTX = SSL_CTX_new(sslMethode);
00030 if(!sslCTX)
00031 THROW(ERROR_C_SSLCTXINIT)
00032
00033 crypt = NET_T_SSL;
00034 }
00035 #else
00036 if(iCrypt != NET_T_NORMAL)
00037 THROW(ERROR_C_NOSSL)
00038 #endif
00039 CATCH
00040 }
|
|
|
Libère la mémoire proprement Définition à la ligne 42 du fichier NetClient.cpp. Références Stop(). 00043 {
00044 Stop();
00045 }
|
|
||||||||||||
|
Envoie des données binaire à iP.
Définition à la ligne 103 du fichier NetClient.h. Références NetConnect::BinSend(). 00104 {
00105 conInfo->BinSend(pBuffer, iSize);
00106 };
|
|
|
Retourne le buffer de données Buffer.
Définition à la ligne 84 du fichier NetClient.h. Références NetConnect::GetBuffer(). 00085 {
00086 return conInfo->GetBuffer();
00087 };
|
|
|
Retourne la taille buffer de données Buffer.
Définition à la ligne 93 du fichier NetClient.h. Références NetConnect::GetBufferSize(). 00094 {
00095 return conInfo->GetBufferSize();
00096 };
|
|
|
Retourne l'objet de connection.
Définition à la ligne 57 du fichier NetClient.h. 00058 {
00059 return conInfo;
00060 };
|
|
|
Retourne l'ip de la connection.
Définition à la ligne 66 du fichier NetClient.h. Références NetConnect::GetIp(). 00067 {
00068 return conInfo->GetIp();
00069 };
|
|
|
Retourne le port de la connection.
Définition à la ligne 75 du fichier NetClient.h. Références NetConnect::GetPort(). 00076 {
00077 return conInfo->GetPort();
00078 };
|
|
|
Recoit les données Buffer depuis Ip. Définition à la ligne 118 du fichier NetClient.h. Références NetConnect::Receive(). 00119 {
00120 conInfo->Receive();
00121 };
|
|
||||||||||||
|
Envoie les données Buffer à Ip.
Définition à la ligne 115 du fichier NetClient.cpp. Références NetConnect::BinSend(). 00116 {
00117 char temp[NET_BUFFER];
00118 va_list args;
00119
00120 va_start(args, pBuffer);
00121 vsprintf(temp, pBuffer, args);
00122 va_end(args);
00123
00124 conInfo->BinSend(temp, strlen(temp));
00125 };
|
|
||||||||||||
|
Démare le client.
Définition à la ligne 47 du fichier NetClient.cpp. Références CATCH, NetConnect::crypt, NetConnect::ip, NetConnect::port, NetConnect::sock, SocketLoad(), NetConnect::sockName, THROW, et TRY. 00048 {
00049 struct hostent *host;
00050 TRY
00051
00052 if(conInfo)
00053 THROW(ERROR_C_ALREADY_START)
00054
00055 conInfo = new NetConnect(crypt);
00056 conInfo->ip = pIp;
00057 conInfo->port = iPort;
00058
00059 if(SocketLoad())
00060 THROW(ERROR_C_LOAD_DLL)
00061
00062 conInfo->sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
00063 if(conInfo->sock < 0)
00064 THROW(ERROR_C_INIT_CONNECT)
00065
00066 host = gethostbyname(conInfo->ip.data());
00067 if(!host)
00068 THROW(ERROR_C_URL_NOTFOUND)
00069
00070 memset(&conInfo->sockName, 0, sizeof(conInfo->sockName));
00071 conInfo->sockName.sin_port = htons(conInfo->port);
00072 conInfo->sockName.sin_family = (*host).h_addrtype;
00073 conInfo->sockName.sin_addr = *((struct in_addr *)(*host).h_addr);
00074
00075 if(connect(conInfo->sock, (const struct sockaddr *)&conInfo->sockName, sizeof(conInfo->sockName)))
00076 THROW(ERROR_C_CONNECT)
00077
00078 #if USE_SSL == 1
00079 if(conInfo->crypt == NET_T_SSL)
00080 {
00081 conInfo->sslFD = SSL_new(sslCTX);
00082 if(!(conInfo->sslFD))
00083 THROW(ERROR_C_SSLINIT)
00084
00085 if(SSL_set_fd(conInfo->sslFD, conInfo->sock) < 1)
00086 THROW(ERROR_C_SSLINIT)
00087
00088 if(SSL_connect(conInfo->sslFD) < 1)
00089 THROW(ERROR_C_SSLCONNECT)
00090 }
00091 #endif
00092
00093 CATCH
00094 }
|
|
|
Arrète le client. Définition à la ligne 96 du fichier NetClient.cpp. Références NetConnect::crypt, NetConnect::sock, SocketClose(), et SocketUnLoad(). Référencé par ~NetClient(). 00097 {
00098 if(conInfo)
00099 {
00100 SocketClose(conInfo->sock);
00101 SocketUnLoad();
00102
00103 #if USE_SSL == 1
00104 if(conInfo->crypt == NET_T_SSL)
00105 {
00106 SSL_shutdown(conInfo->sslFD);
00107 SSL_free(conInfo->sslFD);
00108 }
00109 #endif
00110 delete conInfo;
00111 conInfo = NULL;
00112 }
00113 }
|
1.3.9.1