<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Courier;
        panose-1:2 7 4 9 2 2 5 2 4 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p
        {mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p><font size=3 face=Courier><span style='font-size:12.0pt;font-family:Courier'>My
question(s): <br>
I'm working on a custom network protocol (application layer in TCP/IP <br>
model) for a custom network. &nbsp;Please don't try to talk me out of this. <br>
I'm limiting many of the other protocols, because this is in a highly <br>
secure network, and latency/bandwidth is key. &nbsp;The packet sizes are <br>
minimized by the protocol design, which is ideal. &nbsp;Anyway. &nbsp;I'm
having <br>
some problems with figuring out what to include in the Protocol class, <br>
and what to handle in the server class. &nbsp;Basically, I'm using Telnet, <br>
SMTP, and FTP protocol python files as a reference, and each have <br>
different strutures and methods of doing similar things. &nbsp;Basically, <br>
the protocol I'm developing is very similar to Telnet, so I used this <br>
code as a base. &nbsp;It is necessary to have a state machine, but there is <br>
dynamic information to send as a response to some received messages. <br>
For example, the server may need to get information from a DB, and send <br>
it in a packet as a reponse to a request. &nbsp;I'll give you a sample <br>
implementation, and the remainder of the specific questions below: </span></font><o:p></o:p></p>

<p><font size=3 face=Courier><span style='font-size:12.0pt;font-family:Courier'>server
= a <br>
client = b </span></font><o:p></o:p></p>

<p><font size=3 face=Courier><span style='font-size:12.0pt;font-family:Courier'>1a
= NEED, 1 &nbsp; - NEED is a request to send data from client to server, <br>
1 is the option, or type of data <br>
2b = HAVE, 1 &nbsp; - HAVE is a positive response <br>
3a = NEED, 1 &nbsp; - re-iterated for the purpose of being a server. &nbsp;The <br>
line &quot;1a&quot; is initiated only by a UI command. &nbsp;The line
&quot;3a&quot; is <br>
initiated by as a response to the request &quot;2b&quot;. <br>
4b = PASV, 1 &nbsp;- same as FTP. &nbsp;It's basically, &quot;Well, I have
data...what <br>
port can I send it on?&quot; <br>
4a = PORT, 1, 51000 - not the same as FTP. &nbsp;It's the command, option, <br>
and port number <br>
5b = ACK &nbsp; &nbsp; &nbsp; - acknowledge <br>
ok...now they both disconnect, or stop communication on this port, and <br>
server dynamically opens port 51000 <br>
on port 51000: <br>
6b - &lt;&lt;data stream&gt;&gt; <br>
7a - &lt;&lt;md5 or something other to verify correct and complete&gt;&gt; </span></font><o:p></o:p></p>

<p><font size=3 face=Courier><span style='font-size:12.0pt;font-family:Courier'>Questions
I have: <br>
This is a state machine. &nbsp;The server has a class derived from the <br>
Protocol class whose methods are called prior to the Protocol's. &nbsp;For <br>
example, since the Server is using the derived Protocol class (let's <br>
say it's PProto), whenever a &quot;dataReceived&quot; is fired, PProto picks it
<br>
up, and has to call Protocol's dataReceived handler explicitly. &nbsp;Where <br>
should all of this message handling take place? &nbsp;Should I split up the <br>
duties, like anything that's a singular response to one line should be <br>
in the Protocol class, and anything dynamic can be in the PProto class? </span></font><o:p></o:p></p>

<p><font size=3 face=Courier><span style='font-size:12.0pt;font-family:Courier'>What
about dynamic ports? &nbsp;Where should this be implemented? &nbsp;The <br>
alternative is to have many connections on the one server port. &nbsp;Would <br>
this cause any issues, so that I could eliminate the PASV command <br>
altogether? </span></font><o:p></o:p></p>

<p><font size=3 face=Courier><span style='font-size:12.0pt;font-family:Courier'>I
need to read the data being sent by the client. &nbsp;How can I correctly <br>
intercept this data without effecting the operation of the Protocol, <br>
and also so I can port the Protocol class to other applications without <br>
rewriting the server? </span></font><o:p></o:p></p>

<p><font size=3 face=Courier><span style='font-size:12.0pt;font-family:Courier'>I'm
a newbie :). </span></font><o:p></o:p></p>

<p><font size=3 face=Courier><span style='font-size:12.0pt;font-family:Courier'>Thanks
for your help. </span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>