00001 #ifndef _STR_SocketModule_H_ // -*-c++-*-
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef __GNUG__
00022 # pragma interface
00023 #endif
00024
00025
00026
00027
00028
00029 #include <EHnet++/SocketAddress.h>
00030
00031 #ifndef _STR_StreamFDModule_H_
00032 # include <StrMod/StreamFDModule.h>
00033 #endif
00034
00035 #define _STR_SocketModule_H_
00036
00037 namespace strmod {
00038 namespace strmod {
00039
00040 class SockListenModule;
00041
00042 class SocketModule : public StreamFDModule
00043 {
00044 friend class SockListenModule;
00045
00046 public:
00047 static const STR_ClassIdent identifier;
00048
00049
00050 SocketModule(const ehnet::SocketAddress &addr,
00051 unievent::Dispatcher &disp,
00052 unievent::UnixEventRegistry &ureg,
00053 bool blockconnect = true) throw(unievent::UNIXError);
00054 virtual ~SocketModule();
00055
00056 inline virtual int AreYouA(const lcore::ClassIdent &cid) const;
00057
00058
00059 const ehnet::SocketAddress &GetPeerAddr() { return(peer_); }
00060
00061 protected:
00062 virtual void writeEOF();
00063
00064
00065
00066
00067 SocketModule(int fd, ehnet::SocketAddress *peer,
00068 unievent::Dispatcher &disp,
00069 unievent::UnixEventRegistry &ureg);
00070
00071 virtual const lcore::ClassIdent *i_GetIdent() const { return &identifier; }
00072
00073 static int MakeSocket(SocketModule &obj, const ehnet::SocketAddress &addr,
00074 bool blockconnect) throw(unievent::UNIXError);
00075
00076 private:
00077 ehnet::SocketAddress &peer_;
00078 };
00079
00080
00081
00082 inline int SocketModule::AreYouA(const lcore::ClassIdent &cid) const
00083 {
00084 return((identifier == cid) || StreamFDModule::AreYouA(cid));
00085 }
00086
00087 };
00088 };
00089
00090 #endif