TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: All
from: Jonathan Guthrie
date: 2004-01-28 09:14:36
subject: Re: [C] Question

From: Jonathan Guthrie 

On Wed, Jan 28, 2004 at 07:11:10PM +0530, prabir senapati wrote:

> Dear, folks,  can anyone give me references (url's) or tutorials where i can
> see thru code and study the CLI development of some applications, like
telnet,
> smtp, pop3......
> i wanna learn CLI development in general.

I think you're confused.  You don't want to learn about "CLI" (or
"Command Line Interface") programming, you want to learn how to
implement simple network protocols.  There are two parts to this, learning
how to implement the protocols themselves, something that is often buried
by minutiae in sample source, and learning how to do things like creating a
network server and opening a connection to that server and so forth.

Finding sample code for the latter is easy, but platform-dependent.  So,
what platform is this for?

Finding sample code for the former is not so easy because protocols tend to
be either too easy to bother or too complicated to bother.  For example,
you mention pop3.  The pop3 protocol is oriented around lines. The client
issues a command on a single line and the server responds with one or more
lines of response.  Further, the commands are all four-character codes. 
So, for example, this might be a typical session. To make it clear who
sends what, the characters sent by the server are preceeded by a
"S:" and the characters are sent by the client are preceeded by a
"C:" and all lines end in CRLF (or "\r\n") pairs.

S:+OK POP3 localhost v2003.83 server ready C:USER jguthrie
S:+OK User name accepted, password please C:PASS notMyPassword
S:+OK Mailbox open, 2 messages
C:LIST
S:+OK Mailbox scan listing follows
S:1 1648
S:2 1666
S:.
C:RETR 1
S:+OK 1648 octets
S:Return-path: 
S:Envelope-to: jguthrie{at}brokersys.com

... Lines deleted because I'm too lazy to copy them...

S:
S:.
C:QUIT
S:+OK Sayonara

If you can process input into lines and do what they say, and you can
establish a network connection, you can do a POP3 server or client.  The
commands are specified in RFC 1939, which defines POP3.

Telnet is harder because the Telnet protocol includes a method for
negotiating optional, well, options, which are not specified in the base
Telnet protocol, so you have to read a lot of documentation in addition to
the Telnet RFC.  (I personally always implement the "randomly
lose" option specified in RFC 748, but I've never seen a client that
said "yes" to that.)

SMTP is even easier than POP3 because it's organized into lines like POP3,
but there's only 10 commands to implement.  Beware, however, that the
functionality of an SMTP server is not defined by the SMTP protocol. If you
don't know how email is supposed to work on the server side, you likely
won't be able to do much of anything useful with SMTP on the server side.
--
Jonathan Guthrie (jguthrie{at}brokersys.com) Sto pro veritate

--- BBBS/LiI v4.01 Flag-5
* Origin: Prism's_Point (1:261/38.1)
SEEN-BY: 633/267 270
@PATH: 261/38 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.