Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Namespace Members   Data Fields   Globals  

ExCSocket.cpp

Go to the documentation of this file.
00001 // Socket.cpp: implementation of the ExCSocket class.
00002 //
00004 #include "ExCSocket.h"
00006 // Construction/Destruction
00008 
00009 ExCSocket::ExCSocket(){Guard(ExCSocket::ExCSocket())
00010         m_Port=5000;
00011         m_hSocket=socket(AF_INET,SOCK_STREAM,0);
00012         if(m_hSocket==-1)
00013         {
00014                 EXC
00015         }
00016 UnGuard
00017 }
00018 
00019 ExCSocket::ExCSocket(int Handler){Guard(ExCSocket::ExCSocket(int handler))
00020         SetHandler(Handler);
00021 UnGuard
00022 }
00023 
00024 ExCSocket::ExCSocket(int * Handler){Guard(ExCSocket::ExCSocket(int handler))
00025         SetHandler(*Handler);
00026 UnGuard
00027 }
00028 
00029 ExCSocket::ExCSocket(ExCSocket& socket){Guard(ExCSocket::ExCSocket(ExCSocket& socket))
00030         m_Port=socket.GetHandler();
00031         m_hSocket=socket.GetHandler();
00032         m_pIP=socket.GetIp();
00033 UnGuard
00034 }
00035 
00036 
00037 
00038 ExCSocket::ExCSocket(int domaine,int protocole){Guard(ExCSocket::ExCSocket(int domaine,int protocole))
00039         m_hSocket=socket(domaine,protocole,0);
00040         if(m_hSocket==-1)
00041         {
00042                 EXC
00043         }
00044 UnGuard
00045 }
00046 
00047 ExCSocket::~ExCSocket(){Guard(ExCSocket::~ExCSocket())
00048         close(m_hSocket);
00049 UnGuard
00050 }
00051 
00053 // Function
00055 
00056 void ExCSocket::Init(void){Guard(ExCSocket::Init(void))
00057 
00058         if((m_pInfosHost=gethostbyname("lore"))==0)
00059         {
00060                 EXC
00061         }
00062         memcpy(&m_AdresseIP,m_pInfosHost->h_addr,m_pInfosHost->h_length);
00063                 m_pIP= new char[15];
00064         sprintf(m_pIP,"%s",inet_ntoa(m_AdresseIP));
00065 
00066         memset(&m_AdresseSocket,0,sizeof(struct sockaddr_in));
00067         m_AdresseSocket.sin_family= AF_INET;//le domaine
00068         m_AdresseSocket.sin_port=htons(m_Port);
00069         memcpy(&m_AdresseSocket.sin_addr,m_pInfosHost->h_addr,m_pInfosHost->h_length);
00070         
00071 UnGuard
00072 }
00073 
00074 char * ExCSocket::GetIp(void){Guard(ExCSocket::GetIp(void))
00075         return m_pIP;
00076 UnGuard
00077 }
00078 
00079 int ExCSocket::GetSocketPort(void){Guard(ExCSocket::GetSocketPort())
00080         return m_Port;
00081 UnGuard
00082 }
00083 
00084 void ExCSocket::SetSocketPort(int port){Guard(ExCSocket::SetSocketPort(int port))
00085         m_Port=port;
00086 UnGuard
00087 }
00088 
00089 int ExCSocket::GetHandler(){Guard(ExCSocket::GetHandler())
00090         return m_hSocket;
00091 UnGuard
00092 }
00093 
00094 void ExCSocket::SetHandler(int handler){Guard(ExCSocket::SetHandler())
00095         m_hSocket=handler;
00096 UnGuard
00097 }
00098 
00099 void ExCSocket::Close(void){Guard(void ExCSocket::Close(void))
00100         close(m_hSocket);
00101 UnGuard
00102 }

Generated on Tue Dec 10 18:20:05 2002 for ExNihilo by doxygen1.3-rc1