00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CERTI_SOCKET_UN_HH
00021 #define CERTI_SOCKET_UN_HH
00022
00023 #if defined(RTIA_USE_TCP)
00024 #include "SocketTCP.hh"
00025 #else
00026 #include <netdb.h>
00027 #include <sys/socket.h>
00028 #endif
00029
00030 #define NOM_FICHIER_SOCKET ".comFedRTI"
00031 #include "Socket.hh"
00032 #include "PrettyDebug.hh"
00033
00034 namespace certi {
00035
00036
00037
00038
00039
00040
00041 typedef enum { stSignalInterrupt, stIgnoreSignal } SignalHandlerType ;
00042
00043
00044
00045
00046
00047
00062 class CERTI_EXPORT SocketUN
00063 {
00064 public:
00065 SocketUN(SignalHandlerType theType = stSignalInterrupt);
00066 ~SocketUN();
00067
00068 #ifdef _WIN32
00069 void connectUN(int Server_pid);
00070 #else
00071 int connectUN(pid_t Server_pid);
00072 #endif
00073 void acceptUN(int RTIA_port);
00074
00075 bool isDataReady();
00076
00077 #ifdef _WIN32
00078 SOCKET returnSocket();
00079 #else
00080 int returnSocket();
00081 #endif
00082
00083 void send(const unsigned char *, size_t) throw (NetworkError, NetworkSignal);
00084 void receive(const unsigned char *, size_t) throw (NetworkError, NetworkSignal);
00085
00086 protected:
00087 void error(const char *) throw (NetworkError);
00088
00089 #ifdef _WIN32
00090 SOCKET _socket_un;
00091 #else
00092 int _socket_un;
00093 #endif
00094
00095 bool _est_serveur ;
00096 bool _est_init_un ;
00097
00098 SignalHandlerType HandlerType ;
00099
00100 std::string name ;
00101
00102 private:
00103
00104 Socket::ByteCount_t SentBytesCount ;
00105 Socket::ByteCount_t RcvdBytesCount ;
00106
00107
00108 int sock_connect ;
00109
00110 pdCDebug *pD ;
00111
00112 #ifdef SOCKUN_BUFFER_LENGTH
00113
00114
00115
00116
00117 char ReadBuffer[SOCKUN_BUFFER_LENGTH] ;
00118 unsigned long RBLength ;
00119 #endif
00120 };
00121
00122 }
00123
00124 #endif // CERTI_SOCKET_UN_HH