00001 00011 #ifndef TCPCONVERGENCELAYER_H_ 00012 #define TCPCONVERGENCELAYER_H_ 00013 00014 #include "ConvergenceLayer.h" 00015 #include "utils/Service.h" 00016 #include "utils/MutexLock.h" 00017 #include "utils/Mutex.h" 00018 #include "data/NetworkFrame.h" 00019 #include <list> 00020 00021 using namespace dtn::data; 00022 using namespace dtn::utils; 00023 00024 namespace dtn 00025 { 00026 namespace core 00027 { 00028 class TCPConnection; 00029 00033 class TCPConvergenceLayer : public Service, public ConvergenceLayer 00034 { 00035 friend class TCPConnection; 00036 00037 public: 00043 TCPConvergenceLayer(string localeid, string bind_addr, unsigned short port); 00044 00048 virtual ~TCPConvergenceLayer(); 00049 00053 virtual TransmitReport transmit(const Bundle &b); 00054 00058 virtual TransmitReport transmit(const Bundle &b, const Node &node); 00059 00063 virtual void tick(); 00064 00065 protected: 00066 void callbackBundleReceived(const TCPConnection &conn, Bundle &b); 00067 00068 private: 00069 TransmitReport transmit(TCPConnection *conn, const Bundle &b); 00070 TCPConnection* newConnection(int socket); 00071 bool build_select_list(); 00072 void setnonblocking(int sock); 00073 00074 int m_socket; 00075 00076 static const int DEFAULT_PORT; 00077 00078 string m_selfaddr; 00079 unsigned int m_selfport; 00080 00081 Mutex m_writelock; 00082 Mutex m_mutex_connections; 00083 00084 list<TCPConnection*> m_connections; 00085 00086 fd_set m_socks_recv; 00087 fd_set m_socks_send; 00088 00089 int m_highsock; 00090 00091 NetworkFrame m_contactheader; 00092 00093 string m_localeid; 00094 }; 00095 } 00096 } 00097 00098 #endif /*TCPCONVERGENCELAYER_H_*/
1.5.6