00001 #ifndef N2NC_NETSOCKET_H 00002 #define N2NC_NETSOCKET_H 00003 00004 #include "nixsys.h" 00005 #include "socketaddress.h" 00006 #include "logger.h" 00007 00008 namespace n2nc { 00009 namespace net { 00010 00016 class Socket{ 00017 public: 00018 ~Socket(); 00024 virtual int open(SocketAddress &addr); 00026 virtual int send(void *buf, size_t len); 00028 virtual size_t recvCheck(); 00030 virtual int recv(void *buf, size_t len); 00032 virtual int close(); 00034 virtual int bind(SocketAddress &addr); 00036 virtual bool isConnected(); 00037 00038 typedef int fd_t; 00039 00041 int getAddressFamily(); 00043 int getType(); 00045 fd_t getFD() const ; 00048 int setSockOpt(int optname,bool value,int level=SOL_SOCKET); 00050 bool getSockOpt(int optname,int level=SOL_SOCKET); 00052 SocketAddress* getLocalSocketAddress() const; 00054 SocketAddress* getRemoteSocketAddress() const; 00055 00056 protected: 00060 Socket(int af, int type); 00062 int m_fd ; 00063 int m_af; 00064 int m_type; 00065 void *m_buf_dirty ; 00066 // private: 00067 Socket(); 00068 00073 }; 00074 00075 } 00076 } 00077 00078 #endif