00001 /************************************************************************/ 00002 /* Ex Nihlo Engine by Hermanns Christophe */ 00003 /************************************************************************/ 00004 /* This program is free software; you can redistribute it and/or */ 00005 /* modify it under the terms of the GNU General Public License */ 00006 /* as published by the Free Software Foundation; either version 2 */ 00007 /* of the License, or (at your option) any later version. */ 00008 /* */ 00009 /* This program is distributed in the hope that it will be useful, */ 00010 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 00011 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ 00012 /* */ 00013 /* See the GNU General Public License for more details. */ 00014 /* */ 00015 /* You should have received a copy of the GNU General Public License */ 00016 /* along with this program; if not, write to the Free Software */ 00017 /* Foundation, Inc., 59 Temple Place - Suite 330, */ 00018 /* Boston, MA 02111-1307, USA. */ 00019 /* */ 00020 /* If you use a important part of this code please send me a mail */ 00021 /* I just want to see where my code go thks :) */ 00022 /************************************************************************/ 00023 00024 /************************************************************************/ 00025 /* Contact */ 00026 /************************************************************************/ 00027 /* ExNihilo Website :www.ploksoftware.org */ 00028 /* */ 00029 /* Hermanns Christophe ExNihilo creator and main programmer */ 00030 /* */ 00031 /* Mail : Data@ploksoftware.org */ 00032 /* ICQ : 8030901 */ 00033 /* MSN Messenger : Data_7@hotmail.com */ 00034 /* */ 00035 /* */ 00036 /************************************************************************/ 00037 00038 /************************************************************************/ 00039 /* File Description */ 00040 /************************************************************************/ 00041 /* File Name :ExCSocket.h */ 00042 /* */ 00043 /* Star Date :22/09/2002 */ 00044 /* */ 00045 /* Last Update :06/20/2003 */ 00046 /* */ 00047 /* File Description : */ 00048 /* */ 00049 /* For update of this file check : www.ploksoftware.org */ 00050 /************************************************************************/ 00051 00052 #ifndef __EXCSOCKET_H__ 00053 #define __EXCSOCKET_H__ 00054 //------------------------------------------------------------------------ 00055 //Includes 00056 //------------------------------------------------------------------------ 00057 #include "ExDefine.h" 00058 #if _WIN32 00059 #include <winsock2.h> 00060 #else 00061 #include <unistd.h> 00062 #include <sys/types.h> 00063 #include <sys/socket.h> 00064 #include <netdb.h> 00065 #include <netinet/in.h> 00066 #include <netinet/tcp.h> 00067 #include <arpa/inet.h> 00068 #include <errno.h> 00069 #endif 00070 #include "NetWork/ExCMessage.h" 00071 //------------------------------------------------------------------------ 00072 class ExCSocket 00073 { 00074 public: 00075 //------------------------------------------------------------------------ 00076 // Variable 00077 //------------------------------------------------------------------------ 00078 int m_Port; 00079 std::string m_pIP; 00080 int m_hSocket; 00081 struct hostent *m_pInfosHost; //info sur le host(gethost by name) 00082 struct in_addr m_AdresseIP; //Adress internet format rzo 00083 struct sockaddr_in m_AdresseSocket; //Structure de type sockaddr 00084 public: 00085 //------------------------------------------------------------------------ 00086 // Constructor // Destructor 00087 //------------------------------------------------------------------------ 00088 ExCSocket(); 00089 ExCSocket(ExCSocket& socket); 00090 ExCSocket(int Handler); 00091 ExCSocket(int * Handler); 00092 ExCSocket(int domaine,int protocole); 00093 ~ExCSocket(); 00094 //------------------------------------------------------------------------ 00095 // Methode 00096 //------------------------------------------------------------------------ 00097 void Init(void); 00098 void Close(void); 00099 int GetHandler(void){return m_hSocket;} 00100 void SetHandler(int handler){m_hSocket=handler;} 00101 std::string GetIp(void){return m_pIP;} 00102 void SetIp(std::string ip){m_pIP=ip;} 00103 int GetSocketPort(void){return m_Port;} 00104 void SetSocketPort(int port){m_Port=port;} 00105 00106 00107 void SendMessage(ExCMessage &OutMessage); 00108 void RecvMessage(ExCMessage &InMessage); 00109 00110 }; 00111 //------------------------------------------------------------------------ 00112 #endif //__EXCSOCKET_H__