Network pass-through/proxy server questions
jos_usenet at theorganization.net
Sun Sep 19 17:29:59 CEST 2004
I doing a project which uses Macromedia's Flash program and Python. This
is a 'because i want to see if i can do it' kind of thing, so i know
that there will be better/easier ways to accomplish what i'm about to
I am going to use a flash app as a kind of chat app, but because Flash
does not accept incoming socket connections, i'd like to use a small
Python server to act as the socket proxy (i think that's the right term)
server. I am going to have a flash app running which will connect to the
Python server (the chat app), and i just need the Python server to
accept new client socket connections, and pass the messages received on
to the flash app.
I've gotten a basic version of this running, where the flash chat app
connects on port 9999, and the clients connect on port 8888 (just
example port #).
My biggest problem within the Python code is how to pass a reference to
the flash app about which socket is associated with which
message/client. ie. how do i 'number' the messages, so that when they
are passed to the flash controller, it can then send back messages which
get sent to the correct client?
I currently have used a 'broadcast' method (using weak refs), but this,
obviously, is not very efficient, as each socket compares an internal ID
number against an id which is sent as part of the message from the flash
controller app. ie. each message from a client has an ID pre-pended to
it - "001 Hey how's it going?", and messages from the server are similar
- "001 Kicked due to ineptness"
Is there a way to relate socket objects with some kind of ID, directly,
without fubaring the garbage collection stuff?
Is this clear, or are you all just going "wtf is he talking about?" ;)
ps. i would like to avoid using Twisted, as i want to learn how to use
asyncore on its own, and Twisted just seems too big for what i want...
More information about the Python-list