00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CERTI_SOCKET_MC_HH
00021 #define CERTI_SOCKET_MC_HH
00022
00023 #include "Socket.hh"
00024 #include "NetworkMessage.hh"
00025
00026 #ifdef _WIN32
00027 #ifndef _WINSOCK2API_
00028 #ifndef _WINSOCKAPI_
00029 #include <winsock.h>
00030 #endif
00031 #endif
00032 #if __MINGW32__
00033 #define IP_ADD_MEMBERSHIP 5
00034 struct ip_mreq {
00035 struct in_addr imr_multiaddr;
00036 struct in_addr imr_interface;
00037 };
00038 #endif
00039 #else
00040 #include <sys/socket.h>
00041 #include <netinet/in.h>
00042 #endif
00043 namespace certi {
00044
00045 class SocketMC : public Socket
00046 {
00047 public:
00048 int _socket_mc ;
00049 bool _est_init_mc ;
00050
00051 SocketMC();
00052 virtual ~SocketMC();
00053
00054 void CreerSocketMC(char *addr, unsigned long port);
00055 void CreerSocketMC(unsigned long addr, unsigned long port);
00056
00057 virtual void send(const unsigned char *, size_t)
00058 throw (NetworkError, NetworkSignal);
00059 virtual void receive(void *Buffer, unsigned long Size)
00060 throw (NetworkError, NetworkSignal);
00061
00062 #ifdef _WIN32
00063 SOCKET returnSocket();
00064 #else
00065 virtual int returnSocket();
00066 #endif
00067
00068 virtual unsigned long returnAdress() const ;
00069 virtual void close();
00070
00071 void sendMC(NetworkMessage *msg);
00072 char *receiveMC(NetworkMessage *msg);
00073
00074 private:
00075 struct sockaddr_in _sin ;
00076 struct sockaddr_in _sin_e ;
00077 #ifdef _WIN32
00078 int _sinlen;
00079 SOCKET _socket_emetteur;
00080 #else
00081 socklen_t _sinlen;
00082 int _socket_emetteur;
00083 #endif
00084 int _sinlen_e ;
00085
00086 int timeoutMC(int, int);
00087
00088 int _num_msg ;
00089 };
00090
00091 }
00092
00093 #endif // CERTI_SOCKET_MC_HH