1 // echo.h -*- C++ -*- socket library 2 // Copyright (C) 1992-1996 Gnanasekaran Swaminathan <gs4t@virginia.edu> 3 // 4 // Permission is granted to use at your own risk and distribute this software 5 // in source and binary forms provided the above copyright notice and this 6 // paragraph are preserved on all copies. This software is provided "as is" 7 // with no express or implied warranty. 8 // 9 // Version: 12Jan97 1.11 10 11 #ifndef ECHO_H 12 #define ECHO_H 13 14 #include <socket++/protocol.h> 15 16 class MY_API echo: public protocol 17 { 18 public: 19 class MY_API echobuf: public protocol::protocolbuf { 20 public: echobuf(sockinetbuf & si)21 echobuf (sockinetbuf& si): protocol::protocolbuf (si) {} echobuf(protocol::p_name pname)22 echobuf (protocol::p_name pname) : protocol::protocolbuf (pname) {} 23 24 void serve_clients (int portno = -1) override; rfc_name()25 const char* rfc_name () const override { return "echo"; } rfc_doc()26 const char* rfc_doc () const override { return "rfc862"; } 27 }; 28 29 protected: echo()30 echo (): std::ios(nullptr) {} 31 32 public: echo(protocol::p_name pname)33 echo (protocol::p_name pname) 34 : std::ios (nullptr) 35 { 36 std::ios::init (new echobuf (pname)); 37 } ~echo()38 ~echo () override { delete std::ios::rdbuf (); std::ios::init (nullptr); } 39 rdbuf()40 echobuf* rdbuf () { return (echobuf*) protocol::rdbuf (); } 41 echobuf* operator -> () { return rdbuf (); } 42 }; 43 44 #endif // !ECHO_H 45