| 1 |
// echo.h -*- C++ -*- socket library |
| 2 |
// Copyright (C) 1992,1993,1994 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 |
| 6 |
// notice and this paragraph are preserved on all copies. |
| 7 |
// This software is provided "as is" with no express or implied warranty. |
| 8 |
// |
| 9 |
// Version: 17Oct95 1.10 |
| 10 |
|
| 11 |
#ifndef ECHO_H |
| 12 |
#define ECHO_H |
| 13 |
|
| 14 |
#include <protocol.h> |
| 15 |
|
| 16 |
class echo: public protocol |
| 17 |
{ |
| 18 |
public: |
| 19 |
class echobuf: public protocol::protocolbuf { |
| 20 |
public: |
| 21 |
echobuf (sockbuf& si): protocol::protocolbuf (si) {} |
| 22 |
echobuf (protocol::p_name pname) : protocol::protocolbuf (pname) {} |
| 23 |
|
| 24 |
virtual void serve_clients (int portno = -1); |
| 25 |
virtual const char* rfc_name () const { return "echo"; } |
| 26 |
virtual const char* rfc_doc () const { return "rfc862"; } |
| 27 |
}; |
| 28 |
|
| 29 |
protected: |
| 30 |
echo (): ios(0) {} |
| 31 |
|
| 32 |
public: |
| 33 |
echo (protocol::p_name pname) |
| 34 |
: ios (0) |
| 35 |
{ |
| 36 |
ios::init (new echobuf (pname)); |
| 37 |
} |
| 38 |
~echo () { delete ios::rdbuf (); ios::init (0); } |
| 39 |
|
| 40 |
echobuf* rdbuf () { return (echobuf*) protocol::rdbuf (); } |
| 41 |
echobuf* operator -> () { return rdbuf (); } |
| 42 |
}; |
| 43 |
|
| 44 |
#endif // !ECHO_H |