From: | Andrew Markwell |
Date: | 15 Jul 2000 at 00:46:32 |
Subject: | Re: itstream? |
>From: Johan Rasten <alt@gothik.nu>
>
>Hi again! Would it be possible to create a C++ telnet stream, so you could
>send and recieve data easily?
>
Yeah.. you have 2 options; you can either use istream and ostream as base
classes and take advantage of their ready-made processing methods like
get(), putback(), etc. But since most compilers implement their streams
very differently this might be quite difficult. If you really want to do it
this way, try looking in fstream.h for a helping hand - this contains
ifstream and ofstream which are themselves sub-classes of istream and
ostream.
The other option is to do write a new class which could look something like
this:
class TelnetStream
{
public:
Telnet();
Telnet(char*); // create an object and connect straight away
~Telnet();
open(char*);
get(char&); // like its istream equiv
getline(char*) // " "
put(char&); // like its ostream equiv
putline(char*); // " "
private:
// private stuff
};
You will have to write all the socket I/O stuff and the code to do with the
telnet protocol yourself, but that isn't too hard, and most often you don't
need much of the fancy telnet codes anyway (there are 8 or 9 RFC's on
various telnet extensions), I wrote a telnet-talker server which happily
just sends plain text. In the private section you would probably have a
socket descriptor. If you wanted it to be really polished then you could
overload getline() to ">>" and putline() to "<<".
Andrew Markwell
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
------------------------------------------------------------------------
It's the End Of The Line for My Shipping Broker.
http://click.egroups.com/1/5175/1/_/451227/_/963618393/
------------------------------------------------------------------------