🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #951

Re: an idea to consider

#951
From: Alan Shiers
Date: Tue, 09 Jul 2002 15:48
142 lines
7752 bytes
Hi,

So, if I was to implement line oriented protocol I would just be reading
in UTF-8 strings only. Is that right?

Then when I read in the string, I would have to use StringTokenizer to
separate out a command like: shutdown appname<CR><LF>
to separate both the command from the added argument?  In this case, the
name of the application?

Why does there always have to be carraige return and line feed
characters at the end of every command?  Don't they automatically appear
at the end of the string anyway when we press the ENTER key?  I mean, we
don't actually see them, they're just appended in the terminal window to
whatever we type, don't they?  So, really, in the terminal window we
would just type:
shutdown appname [ENTER]?

Does this Oro have a web address where I can obtain these NetComponents
classes you mentioned?  I've tried www.oro.com and www.oro.org. Both
were strange web sites.  Not what I'm looking for I don't think.

Do you recommend a particular Telnet program I can get?  If I'm going to
use one I might as well get one that suites my purposes.

Alan



"John McGrath [TeamB]" wrote:
> 
> On Mon, 08 Jul 2002 22:21:44 -0400, Alan Shiers wrote:
> 
> > I'm not familiar with telnet as I never have had an occasion
> > to use it. Perhaps you can explain briefly what line-oriented
> > protocol is and line terminators.  What are those?  Could you
> > show me some examples?  I'm not familiar with CR-LF.
> 
> The protocol you have implemented looks something like this:  A
> message consists of a UTF-8 string (the characters preceded by a
> two-byte length) followed by an integer.  The string specifies the
> program name.  The integer is a command, with 99 meaning SHUTDOWN.
> 
> When I say a line oriented protocol, I mean something like this:
> A message consists of a variable length string of characters followed
> by a Carriage Return and a Line Feed (i.e. CR-LF).  The first part of
> the messages is the command, which is a string of non-blank characters.
> If the command has parameters, it is followed by a space and then the
> parameters, with a space between each parameter.
> 
> So the shutdown command might look like this:
> 
>    shutdown appname<CR><LF>
> 
> Note the <CR> and <LF> stand for the ASCII Carriage-Return (hex 0D) and
> Line-Feed (hex 0A) characters.
> 
> Now say your application keeps track of users and widgets.  You might
> add a diagnostic "show" command with an argument indicating what to
> show:
> 
>    show users<CR><LF>
>    show widgets<CR><LF>
> 
> Now that you have several commands, you might add a help command that
> takes no arguments:
> 
>    help<CR><LF>
> 
> Telnet is a terminal emulation program.  You can use it to connect to
> another system (that has a telnet server running) and that generally
> gives you a "console" interface to that system.  If I telnet to a
> Windows system, I can type commands through the telnet interface that
> I could type in a "DOS" window and the output from the commands will
> appear in the telnet window.
> 
> A telnet client just opens a socket connection to the other system and
> writes what you type to the socket.  It also reads from the socket and
> displays that in the telnet window.  So instead of using your client
> program to connect to your server, you can use telnet.  You will need
> to tell it which port to use rather than the default telnet port (23),
> but aside from that, telnet will work just fine as the client for a
> server that is written this way.
> 
> One advantage of this is that it makes it very easy to debug your
> server.  If you use telnet to connect to it, you will know for sure
> what characters are being sent to the server, since you just type them.
> 
> Two protocols that work this way are NNTP and SMTP, which are used for
> news and for mail respectively.  The default port for NNTP is 119 and
> for SMTP it is 25.  NNTP servers generally have a help command, so it
> is somewhat self-documenting.  You can try connecting to the news
> server or to your local mail server to see what I mean.  To connect to
> the borland NNTP server, you would use the command:
> 
>    telnet newsgroups.borland.com 119
> 
> The format of the commands that you see there is exactly the same as
> those that are being used by your news reader when you use it.
> 
> Two things you might note about the responses from the server.  One is
> that command replies always consist of a 3 digit number, a space,
> followed by a descriptive text string.  The number is intended for
> programs to use and the text string is for display to the user.  For
> example, if I type the command "group xxxx", since there is no group by
> that name, it will respond:
> 
>    411 no such newsgroup
> 
> This means you do not have to know or look up these codes when you
> connect this way.
> 
> You might also note that when something more than a simple status reply
> is needed, it writes the response as a series of lines (each terminated
> by CT-LF) followed by a line consisting of a single ".".  If one of the
> response lines begins with a ".", it will throw in an additional ".",
> so a line starting with ".." actually means a single ".".
> 
> Obviously, none of the specifics here are required.  You define the
> protocol and as long as your client and server speak the same language,
> they should work.  But this approach is used in several protocols which
> makes it easier to understand, and it works well.
> 
> There is a more code to write than your one-shot protocol, but it is
> not too hard to implement.  The Oro NetComponents library has classes
> that do some of the work, although it could do a lot more.  I wrote
> some classes on my last job that handled just about everything that
> NetComponents did not handle -- everything but the actual command
> implementations.  Given those classes, writing a new server and client
> took significantly less additional code than your protocol.
> 
> Hmmmm.  That turned out longer than I though it would.  I hope I
> covered the questions.  Let me know if I missed something.
> 
> --
> Regards,
> 
> John McGrath [TeamB]
> 
> ---------------------------------------------------
> Before sending me e-mail, please read:
>     http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <3D2B05DA.EE3D2DC2@hfx.eastlink.ca>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-08!supernews.com!news.tele.dk!small.news.tele.dk!4.1.16.34!cpk-news-hub1.bbnplanet.com!news.gtei.net!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3D279D25.59AA52E@hfx.eastlink.ca> <3d27a0b2_2@dnews> <3D2861BB.63220DF5@hfx.eastlink.ca> <MPG.17923b35889aef9498b7f9@newsgroups.borland.com> <3D28A22A.89CB73DC@hfx.eastlink.ca> <MPG.1793793e26a87ab98b7fd@newsgroups.borland.com> <3D29FE4E.C3EEF5B5@hfx.eastlink.ca> <MPG.1793eed4e5e42ee798b80b@newsgroups.borland.com> <3D2A48B8.29314379@hfx.eastlink.ca> <MPG.17946a495a7d5f5e98b812@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,4157c064c52214d4
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-07-09 08:04:17 PST
Message-ID: <3D2B05DA.EE3D2DC2@hfx.eastlink.ca>
Date: Tue, 09 Jul 2002 11:48:42 -0400
From: Alan Shiers <ashiers@hfx.eastlink.ca>
Organization: Mustard Seed Software
X-Mailer: Mozilla 4.78 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.api
Subject: Re: an idea to consider
References: <3D279D25.59AA52E@hfx.eastlink.ca> <3d27a0b2_2@dnews> <3D2861BB.63220DF5@hfx.eastlink.ca> <MPG.17923b35889aef9498b7f9@newsgroups.borland.com> <3D28A22A.89CB73DC@hfx.eastlink.ca> <MPG.1793793e26a87ab98b7fd@newsgroups.borland.com> <3D29FE4E.C3EEF5B5@hfx.eastlink.ca> <MPG.1793eed4e5e42ee798b80b@newsgroups.borland.com> <3D2A48B8.29314379@hfx.eastlink.ca> <MPG.17946a495a7d5f5e98b812@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.222.101.2
X-Trace: dnews 1026225976 24.222.101.2 (9 Jul 2002 07:46:16 -0700)
Lines: 142
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-08!supernews.com!news.tele.dk!small.news.tele.dk!4.1.16.34!cpk-news-hub1.bbnplanet.com!news.gtei.net!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews