473,396 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Twisted server and protocol question

Hi guys. I hope I can discuss Twisted here. If not, direct me to the
correct place please.

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

server = a
client = b

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

Questions I have:
This is a state machine. The server has a class derived from the
Protocol class whose methods are called prior to the Protocol's. For
example, since the Server is using the derived Protocol class (let's
say it's PProto), whenever a "dataReceived" is fired, PProto picks it
up, and has to call Protocol's dataReceived handler explicitly. Where
should all of this message handling take place? Should I split up the
duties, like anything that's a singular response to one line should be
in the Protocol class, and anything dynamic can be in the PProto class?
What about dynamic ports? Where should this be implemented? The
alternative is to have many connections on the one server port. Would
this cause any issues, so that I could eliminate the PASV command
altogether?

I need to read the data being sent by the client. How can I correctly
intercept this data without effecting the operation of the Protocol,
and also so I can port the Protocol class to other applications without
rewriting the server?

I'm a newbie :).

Thanks for your help.

Aug 28 '06 #1
1 2668

Benry wrote:
Hi guys. I hope I can discuss Twisted here. If not, direct me to the
correct place please.
Twisted mailing list:
http://twistedmatrix.com/cgi-bin/mai...twisted-python

;-)
~Simon

Aug 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Paul Moore | last post by:
I hit a problem yesterday with my mail connection. In a desparate attempt to understand what was going on, I wanted to log the connection traffic. After a bit of searching, I found a post on c.l.p...
11
by: mir nazim | last post by:
hi, i m planning to start writing intranet applications and want ur real cool advices for choosing the correct platform. the choice is between the three: 1. Twisted 2. Medusa 3. Zope (i do...
2
by: Qp | last post by:
Hello. I'm building a simple chat server and client interface, and I've got everything working except for this: While the client's basic.LineReceiver protocol class can sendLine when a...
3
by: Rico Huijbers | last post by:
Does anybody have experience in writing Jabber clients with Twisted? I came across a simple sample, and tried to build out from it, but for some reason it's barely working. When I run the...
1
by: PeterG | last post by:
Hi, I am relatively new to Python, and am learning it as part of a university module... Im currently undertaking a project to create an IM server and IM gui client. I have a very basic...
9
by: Chris | last post by:
Does anyone know how to use twisted and tkinter. I have a simple tcp server and I want to send messages to it once connected using a tkinter button? I have built the code as far as I can but...
0
by: Chris | last post by:
Hi, Sorry for reposting but I changed my code and received a new error message so I thought I would try it on the group again. I have a working server and this is meant to be a chat client using...
0
by: James Mills | last post by:
On Fri, Sep 19, 2008 at 6:24 AM, Fredrik Lundh <fredrik@pythonware.comwrote: There is also one more alternative: pymills - current version 3.4 It has a different design goal to twisted and...
0
by: Stodge | last post by:
I'm trying to get a simple multicast application working using Twisted; so far I have: from twisted.internet.protocol import DatagramProtocol from twisted.internet import reactor from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.