⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chattersocket.hh

📁 COPE the first practical network coding scheme which is developped on click
💻 HH
字号:
#ifndef CLICK_CHATTERSOCKET_HH#define CLICK_CHATTERSOCKET_HH#include <click/element.hh>#include <click/error.hh>CLICK_DECLS/*=cChatterSocket("TCP", PORTNUMBER [, I<KEYWORDS>])ChatterSocket("UNIX", FILENAME [, I<KEYWORDS>])=s debuggingreports chatter messages to connected sockets=ioNone=dOpens a chatter socket that allows other user-level programs to receive copiesof router chatter traffic. Depending on its configuration string,ChatterSocket will listen on TCP port PORTNUMBER, or on a UNIX-domain socketnamed FILENAME.The "server" (that is, the ChatterSocket element) simply echoes any messagesgenerated by the router configuration to any existing "clients". The serverdoes not read any data from its clients.When a connection is opened, ChatterSocket responds by stating its protocolversion number with a line like "Click::ChatterSocket/1.0\r\n". The currentversion number is 1.0.ChatterSocket broadcasts copies of messages generated by the defaultErrorHandler or the C<click_chatter> function. Most elements report messagesor run-time errors using one of these mechanisms.If a client falls more than 500,000 bytes behind, ChatterSocket automaticallycloses its connection.ChatterSocket supports hot-swapping, meaning you can change configurationswithout interrupting existing clients. The hot-swap will succeed only if theold ChatterSocket and the new ChatterSocket have the same element name, andthe same socket type, port/filename, and chatter channel parameters.Additionally, the new ChatterSocket must have RETRIES set to 1 or more, sincethe old ChatterSocket has already bound the relevant socket.Keyword arguments are:=over 8=item CHANNELText word. The socket outputs messages sent to this chatter channel. Defaultis the default channel, which corresponds to C<click_chatter()>.Channels help you organize extensive debugging output. For example, you couldsend extremely verbose messages to a `C<verbose>' channel, then only connectto that channel when you want verbosity.To send messages to a particular channel, you should fetch the ErrorHandlerobject corresponding to that channel, using the Router member functionC<Router::chatter_channel(const String &channel_name)>.=item QUIET_CHANNELBoolean. Messages sent to a non-default channel are not normally printed onstandard error. If QUIET_CHANNEL is false, however, the channel's messages dogo to standard error, along with chatter messages. Default is true.=item GREETINGBoolean. Determines whether the C<Click::ChatterSocket/1.0> greeting is sent.Default is true.=item RETRIESInteger. If greater than 0, ChatterSocket won't immediately fail when it can'topen its socket. Instead, it will attempt to open the socket once a seconduntil it succeeds, or until RETRIES unsuccessful attempts (after which it willstop the router). Default is 0.=item RETRY_WARNINGSBoolean. If true, ChatterSocket will print warning messages every time itfails to open a socket. If false, it will print messages only on the finalfailure. Default is true.=back=e  ChatterSocket(unix, /tmp/clicksocket);=a ControlSocket */class Timer;class ChatterSocket : public Element { public:  ChatterSocket();  ~ChatterSocket();  const char *class_name() const	{ return "ChatterSocket"; }    int configure_phase() const	 	{ return CONFIGURE_PHASE_INFO; }  int configure(Vector<String> &conf, ErrorHandler *);  int initialize(ErrorHandler *);  void cleanup(CleanupStage);  void take_state(Element *, ErrorHandler *);  void selected(int);  void handle_text(ErrorHandler::Seriousness, const String &);  void flush(); private:  String _unix_pathname;  int _socket_fd;  String _channel;  bool _greeting : 1;  bool _retry_warnings : 1;  bool _tcp_socket : 1;  Vector<String> _messages;  Vector<uint32_t> _message_pos;  uint32_t _max_pos;    Vector<int> _fd_alive;  Vector<uint32_t> _fd_pos;  int _live_fds;  int _retries;  Timer *_retry_timer;    static const char protocol_version[];  enum { MAX_BACKLOG = 500000 };  int initialize_socket_error(ErrorHandler *, const char *);  int initialize_socket(ErrorHandler *);  static void retry_hook(Timer *, void *);    int flush(int fd);};inline voidChatterSocket::handle_text(ErrorHandler::Seriousness, const String &message){  if (_live_fds && message.length()) {    _messages.push_back(message);    _message_pos.push_back(_max_pos);    _max_pos += message.length();    flush();  }}CLICK_ENDDECLS#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -