Now for a few notes about the implementation classes (aka I haven't had time
to write proper documentation so I'm making it up as I have the chance here).
All 3 servers are written as references to different parts of nfc that I have written
to try to demonstrate how they are used. This means that they aren't necessarily
the best examples of "smart" coding on my part because wherever possible I followed
the pattern that I had set out rather than using the pattern when it was good and using
another when it was bad.
The Finger server is the simplest of the bunch. It is basically the most basic server you can think of. This is really a simple class (probably less than 100 lines of code) so I won't go too
into depth.
The SMTP Server is based on my idea of "plugins" for the server, where each plugin
handles one command from the server. The plugin is responsible for things like:
a) Rejecting command if it's an invalid state for that command
b) Sending the reply to the client
c) Changing to new state if necessary
The interface for this plugin stuff is kind of kludgy IMHO and I'm trying to think of a
way to spruce it up a bit. Any suggestions are welcome.
The POP3 server is based around the state machine stuff that I wrote. Basically,
a lot of protocols on the Internet revolve around discrete states and what commands
are available in that state and what those commands do in that state. So I wrote this
using the state machine idea (if you don't know what state machines are, do a search
on the net). There is a transition listener going into and out of each state which fires in
much the same way as an AWT or Swing event (if that makes sense) which can also
be used to set up stuff that needs to happen between states.
Have fun with this stuff!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Version 0.0.1 (aka snapshot of what I had when I checked in) is now available.
The example servers are:
com.fangr.servers.finger.FingerServer
com.fangr.servers.email.smtp.SMTPServer
com.fangr.servers.email.pop3.POP3Server
and can be run through a command line like this:
java -classpath %CLASSPATH%;nfc.jar;servers.jar <serverclassname>
Now for a few notes about the implementation classes (aka I haven't had time
to write proper documentation so I'm making it up as I have the chance here).
All 3 servers are written as references to different parts of nfc that I have written
to try to demonstrate how they are used. This means that they aren't necessarily
the best examples of "smart" coding on my part because wherever possible I followed
the pattern that I had set out rather than using the pattern when it was good and using
another when it was bad.
The Finger server is the simplest of the bunch. It is basically the most basic server you can think of. This is really a simple class (probably less than 100 lines of code) so I won't go too
into depth.
The SMTP Server is based on my idea of "plugins" for the server, where each plugin
handles one command from the server. The plugin is responsible for things like:
a) Rejecting command if it's an invalid state for that command
b) Sending the reply to the client
c) Changing to new state if necessary
The interface for this plugin stuff is kind of kludgy IMHO and I'm trying to think of a
way to spruce it up a bit. Any suggestions are welcome.
The POP3 server is based around the state machine stuff that I wrote. Basically,
a lot of protocols on the Internet revolve around discrete states and what commands
are available in that state and what those commands do in that state. So I wrote this
using the state machine idea (if you don't know what state machines are, do a search
on the net). There is a transition listener going into and out of each state which fires in
much the same way as an AWT or Swing event (if that makes sense) which can also
be used to set up stuff that needs to happen between states.
Have fun with this stuff!