Python newbie looking into communications...
Sam Marrocco
samSPAMMENOT at twmi.rr.com
Sun Jan 26 15:39:57 EST 2003
Peter Hansen wrote:
>
> What headaches do you feel are involved in "maintaining" TCP connections?
>
> So far as I know, there is *nothing* that must be done by application-
> level code to "maintain" an open connection, except perhaps send and
> receive data using it...
>
Perhaps "maintaining" was the wrong term to use....
Since I've been barraged with "don't use UDP" replies, here's a little
background on what the app does. Be gentle--this has been my first
experience with machine-machine communications.
-The Controller app runs on Windows, and is written (mainly) in vb.net.
-The Node app is a small program that must be portable to windows,
linux, and irix. I chose python for a bunch of reasons, the main one
being portability. The node app may run on dozens (or more) machines at
once.
I started designing the system with TCP in mind--the controller
launches, establishes a connection with each node, and communications
can commence. But soon I realized that:
If the Controller was a TCP Server and the nodes were TCP Clients, the
Controller/server had to be running first, then the Nodes/Clients. If
the Controller/Server was restarted (which happens often)then things
went awry. Also, the Nodes/clients do not necessarily know *who* the
Controller/Server is, so they receive that information within their data
from the Controller/Server--then send info back to that machine. Nodes
and Controller can be rebooted at any time, and the apps restarted.
When I started playing with UDP, I realized that, yes, the "lack of
guarantee" that the data would get there was an issue--which I could
correct for by including acknowledgments and a little handshaking
between machines. But it seemed well worth it for the ability to have a
"server-less" communications arrangement that didn't gag when the server
machine disappeared. UDP peer-peer comm seemed a worthy compromise. I'm
not dealing with large amounts of data--usually small strings, and they
aren't pushed around the network very fast....usually a dialog might be
something like:
Controller: MachineA, run this calculation.
MachineA: Okay, controller, I'm doing that calculation.
Controller: Displays information on what MachineA is doing.
MachineA: Okay, controller, I'm done. Here's the result.
Controller: Okay MachineA. Displays info.
process repeats.....
In my perfect world, all I really wanted was a way to say
SendToMachine(machinename, data)
and an event to catch data
DataReceived(MachineName, data)
But the most important thing was that any machine on the network could
be restarted at any time, *without* having to have a server app always
running.
--
==================================================================
Sam J. Marrocco
Sr. Visual Effects Artist/R&D
Travelling Pictures/GTN
Inferno, Flame, Houdini, Maya, All that cool stuff!
"The fact that no one understands you doesn't make you an artist."
==================================================================
More information about the Python-list
mailing list