00001 /*************************************************************************** 00002 * Copyright (C) 2007 by Pierre Schmitt, Ludovic Giacomello, Nhi Ly * 00003 * * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * 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 * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00021 00022 #ifndef SOCKET_H 00023 #define SOCKET_H 00024 00025 #include <unistd.h> 00026 #include <sys/types.h> 00027 #include <sys/socket.h> 00028 00029 #include <netinet/in.h> 00030 #include <netdb.h> 00031 #include <memory.h> 00032 #include <errno.h> 00033 00034 #include <arpa/inet.h> 00035 00036 00037 #include "Cryptage.h" 00038 #include "EnClair.h" 00039 #include "Vigenere.h" 00040 #include "SocketException.h" 00041 00042 using namespace std; 00043 00044 //Modif client 2... 00045 00049 class Socket { 00050 public: 00055 Socket() { SetCryptage(); } 00056 00062 Socket(int socket){ SetCryptage(); } 00063 00070 Socket(unsigned int port) throw(SocketException) { SetCryptage(); } 00071 00079 Socket(string ad, unsigned int port) throw(SocketException) { SetCryptage(); } 00080 00086 Socket(Socket *s){ 00087 mSocket=s->mSocket; 00088 mCryptage=s->mCryptage; 00089 } 00090 00091 00097 Socket(const Socket &s){ 00098 mSocket=s.mSocket; 00099 mCryptage=s.mCryptage; 00100 } 00101 00106 void operator=(const Socket &s){ 00107 mSocket=s.mSocket; 00108 mCryptage=s.mCryptage; 00109 } 00110 00115 virtual ~Socket(){ 00116 delete mCryptage; 00117 } 00118 00123 virtual Socket* Accept() throw(SocketException)=0; 00124 00129 virtual void Envoyer(string msg) const throw(SocketException)=0; 00130 00135 virtual string Ecouter() throw(SocketException)=0; 00136 00137 protected: 00141 int mSocket; 00142 00146 Cryptage *mCryptage; 00151 void SetCryptage(){ 00152 //mCryptage=new EnClair(); 00153 mCryptage=new Vigenere(); 00154 mCryptage->SetCle("dbzUICSibsFCssqE349Dcs1P5zs491674c6z4c8zHVedz"); 00155 } 00156 }; 00157 00158 #endif