<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. 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. The packet sizes are <br>
minimized by the protocol design, which is ideal. Anyway. 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. 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. Basically, <br>
the protocol I'm developing is very similar to Telnet, so I used this <br>
code as a base. 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. 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 - NEED is a request to send data from client to server, <br>
1 is the option, or type of data <br>
2b = HAVE, 1 - HAVE is a positive response <br>
3a = NEED, 1 - re-iterated for the purpose of being a server. The <br>
line "1a" is initiated only by a UI command. The line
"3a" is <br>
initiated by as a response to the request "2b". <br>
4b = PASV, 1 - same as FTP. It's basically, "Well, I have
data...what <br>
port can I send it on?" <br>
4a = PORT, 1, 51000 - not the same as FTP. It's the command, option, <br>
and port number <br>
5b = ACK - 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 - <<data stream>> <br>
7a - <<md5 or something other to verify correct and complete>> </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. The server has a class derived from the <br>
Protocol class whose methods are called prior to the Protocol's. For <br>
example, since the Server is using the derived Protocol class (let's <br>
say it's PProto), whenever a "dataReceived" is fired, PProto picks it
<br>
up, and has to call Protocol's dataReceived handler explicitly. Where <br>
should all of this message handling take place? 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? Where should this be implemented? The <br>
alternative is to have many connections on the one server port. 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. 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> </o:p></span></font></p>
</div>
</body>
</html>