Page principale Liste des namespaces Hiérarchie des classes Liste par ordre alphabétique Liste des composants Liste des fichiers Membres des namespaces Composants Déclarations

# ExCSocketClient.cpp

Aller à la documentation de ce fichier.

    00001 // SocketClient.cpp: implementation of the ExCSocketClient class.
    00002 //
    00004
    00005 #include "ExCSocketClient.h"
    00006
    00008 // Construction/Destruction
    00010
    00011 ExCSocketClient::ExCSocketClient(){Guard(ExCSocketClient::ExCSocketClient())
    00012         ExCSocket();
    00013 UnGuard
    00014 }
    00015
    00016 ExCSocketClient::ExCSocketClient(int domaine,int protocole){Guard(ExCSocketClient::ExCSocketClient())
    00017         ExCSocket(domaine,protocole);
    00018 UnGuard
    00019 }
    00020
    00021 ExCSocketClient::~ExCSocketClient(){Guard(ExCSocketClient::~ExCSocketClient())
    00022
    00023 UnGuard
    00024 }
    00025
    00026 int ExCSocketClient::Connect(struct sockaddr_in Adresse){Guard(ExCSocketClient::Connect(struct sockaddr_in Adresse))
    00027         int ret=0;
    00028         unsigned int tailleSockaddr_in;
    00029         tailleSockaddr_in=sizeof(struct sockaddr_in);
    00030         if((ret==connect(m_hSocket,(struct sockaddr *)&Adresse,tailleSockaddr_in))==-1)
    00031         {
    00032                 Trace(Erreur sur connect de la socket);
    00033                 Close();
    00034         }
    00035         return ret;
    00036 UnGuard
    00037 }
    00038 int ExCSocketClient::Connect(void){Guard(ExCSocketClient::Connect())
    00039         int ret=0;
    00040         unsigned int tailleSockaddr_in;
    00041         tailleSockaddr_in=sizeof(struct sockaddr_in);
    00042         if((ret==connect(m_hSocket,(struct sockaddr *)&m_AdresseSocket,tailleSockaddr_in))==-1)
    00043         {
    00044                 Trace(Erreur sur connect de la socket);
    00045                 Close();
    00046         }
    00047         return ret;
    00048 UnGuard
    00049 }
    00050
    00051 void ExCSocketClient::SetSocketAdresse(sockaddr_in Adresse){Guard(ExCSocketClient::SetSocketAdresse(sockaddr_in Adresse))
    00052         m_AdresseSocket=Adresse;
    00053 UnGuard
    00054 }
    00055
    00056 struct sockaddr_in ExCSocketClient::GetSocketAdresse(void){Guard(ExCSocketClient::GetSocketAdresse(void))
    00057         return m_AdresseSocket;
    00058 UnGuard
    00059 }
    00060
    00061 void ExCSocketClient::Init(void){Guard(void ExCSocketClient::Init(void))
    00062
    00063         if((m_pInfosHost=gethostbyname("lore"))==0)
    00064         {
    00065                 Trace("Erreur d'aquisition sur le host");
    00066         }
    00067         memcpy(&m_AdresseIP,m_pInfosHost->h_addr,m_pInfosHost->h_length);
    00068                 m_pIP= new char[15];
    00069         sprintf(m_pIP,"%s",inet_ntoa(m_AdresseIP));
    00070
    00071         memset(&m_AdresseSocket,0,sizeof(struct sockaddr_in));
    00072         m_AdresseSocket.sin_family= AF_INET;//le domaine
    00073         m_AdresseSocket.sin_port=htons(m_Port);
    00074         memcpy(&m_AdresseSocket.sin_addr,m_pInfosHost->h_addr,m_pInfosHost->h_length);
    00075
    00076
    00077 UnGuard
    00078 }
    00079
    00080 void ExCSocketClient::Init(char *NAME){Guard(void ExCSocketClient::Init(void))
    00081
    00082         if((m_pInfosHost=gethostbyname(NAME))==0)
    00083         {
    00084                 Trace("Erreur d'aquisition sur le host NAME");
    00085         }
    00086         memcpy(&m_AdresseIP,m_pInfosHost->h_addr,m_pInfosHost->h_length);
    00087                 m_pIP= new char[15];
    00088         sprintf(m_pIP,"%s",inet_ntoa(m_AdresseIP));
    00089
    00090         memset(&m_AdresseSocket,0,sizeof(struct sockaddr_in));
    00091         m_AdresseSocket.sin_family= AF_INET;//le domaine
    00092         m_AdresseSocket.sin_port=htons(m_Port);
    00093         memcpy(&m_AdresseSocket.sin_addr,m_pInfosHost->h_addr,m_pInfosHost->h_length);
    00094
    00095
    00096 UnGuard
    00097 }
    00098
    00099
    00100
    00101
    00102
    00103
    00104
    00105
    00106
    00107
    00108
    00109
    00110
    00111
    00112