Page principale | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de classe | Membres de fichier | Pages associées

Référence de la classe NetClient

Systeme client. Plus de détails...

#include <NetClient.h>

Liste de tous les membres

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.
NetConnectGetConnect ()
 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.


Description détaillée

Client pour le systeme serveur NetServeur.

Définition à la ligne 22 du fichier NetClient.h.


Documentation des contructeurs et destructeur

NetClient::NetClient unsigned int  iCrypt = NET_T_NORMAL  ) 
 

Initialise avec des paramétres par defaut.

Paramètres:
iCrypt active le cryptage SSL

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 }

NetClient::~NetClient  ) 
 

Libère la mémoire proprement

Définition à la ligne 42 du fichier NetClient.cpp.

Références Stop().

00043 {
00044     Stop();
00045 }


Documentation des fonctions membres

void NetClient::BinSend const char *  pBuffer,
unsigned int  iSize
[inline]
 

Envoie des données binaire à iP.

Paramètres:
pBuffer données
iSize Taille des données

Définition à la ligne 103 du fichier NetClient.h.

Références NetConnect::BinSend().

00104     {
00105         conInfo->BinSend(pBuffer, iSize);
00106     };

const char* NetClient::GetBuffer  )  [inline]
 

Retourne le buffer de données Buffer.

Renvoie:
Pointeur sur le buffer.

Définition à la ligne 84 du fichier NetClient.h.

Références NetConnect::GetBuffer().

00085     {
00086         return conInfo->GetBuffer();
00087     };

unsigned int NetClient::GetBufferSize  )  [inline]
 

Retourne la taille buffer de données Buffer.

Renvoie:
Taille du buffer BufferSize.

Définition à la ligne 93 du fichier NetClient.h.

Références NetConnect::GetBufferSize().

00094     {
00095         return conInfo->GetBufferSize();
00096     };

NetConnect* NetClient::GetConnect  )  [inline]
 

Retourne l'objet de connection.

Renvoie:
Pointeur sur l'objet conInfo .

Définition à la ligne 57 du fichier NetClient.h.

00058     {
00059         return conInfo;
00060     };

const char* NetClient::GetIp  )  [inline]
 

Retourne l'ip de la connection.

Renvoie:
Pointeur sur l'ip.

Définition à la ligne 66 du fichier NetClient.h.

Références NetConnect::GetIp().

00067     {
00068         return conInfo->GetIp();
00069     };

unsigned int NetClient::GetPort  )  [inline]
 

Retourne le port de la connection.

Renvoie:
port de la connection.

Définition à la ligne 75 du fichier NetClient.h.

Références NetConnect::GetPort().

00076     {
00077         return conInfo->GetPort();
00078     };

void NetClient::Receive  )  [inline]
 

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     };

void NetClient::Send const char *  pBuffer,
  ...
 

Envoie les données Buffer à Ip.

Paramètres:
pBuffer chaine construite comme pour printf.
... argument pour construire la chaine

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 };

void NetClient::Start const char *  iIp,
unsigned int  iPort
 

Démare le client.

Paramètres:
iIp ip de connection
iPort port de connaection

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 }

void NetClient::Stop  ) 
 

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 }


La documentation de cette classe a été générée à partir des fichiers suivants:
Généré le Thu Jun 12 09:12:30 2008 pour A.I.F. par  doxygen 1.3.9.1