By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,621 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,621 IT Pros & Developers. It's quick & easy.

Asyncore Help?

P: n/a
I am working on the networking code for a small Multiplayer RPG I'm
working on. I currently have some basic code using threads, but it
seems like asyncore would be far better suited for my needs. However,
I have trouble finding a solid example for what I need. Python.org and
other sites provide simple examples, but they appear more intended for
servers that simply send one peice of data to the client.

I want to have a server program that is willing to accept commands
sent from the client, and repeatedly wait for data and respond.
Maintaining a long term connection until the client is done playing.

Besides this I am also stuck with dealing with TCP data streams. I can
receive and send the data (using threads, not yet with asynocore), but
I am unsure how to deal with the streamlike nature of TCP (and would
prefer to use TCP over UDP). I would like to have it so that the
client sends the server a command (such as update position), and then
the data, and have the server update that information on its side
accordingly.

While basic socket work was rather easy to deal with, this has proved
significantly more difficult. Are there any good free sources for
information on Asyncore, and dealing with TCP?
May 14 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Paul Kozik wrote:
While basic socket work was rather easy to deal with, this has proved
significantly more difficult. Are there any good free sources for
information on Asyncore, and dealing with TCP?
You haven't said specifically what you're having a problem with. The
more general name for asyncore/asynchat is Medusa, and there are some
resources with more examples available here:

http://www.nightmare.com/medusa/
http://www.amk.ca/python/code/medusa.html

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
I used to walk around / Like nothing could happen to me
-- TLC
May 14 '07 #2

P: n/a
Erik Max Francis <ma*@alcyone.comwrote:
Paul Kozik wrote:
While basic socket work was rather easy to deal with, this has proved
significantly more difficult. Are there any good free sources for
information on Asyncore, and dealing with TCP?

You haven't said specifically what you're having a problem with. The
more general name for asyncore/asynchat is Medusa, and there are some
resources with more examples available here:

http://www.nightmare.com/medusa/
http://www.amk.ca/python/code/medusa.html
There is also twisted of course if we are talking about async
networking libraries.

http://twistedmatrix.com/trac/

The learning curve of twisted is rather brutal, but it will do
everything you want and a whole lot more! I haven't tried Medusa, but
I've done several things with twisted. It takes a bit of getting your
head round but you'll be impressed with the speed.

--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
May 14 '07 #3

P: n/a

On May 14, 2007, at 4:30 AM, Nick Craig-Wood wrote:
The learning curve of twisted is rather brutal
:-)

May 14 '07 #4

P: n/a
Nick Craig-Wood wrote:
http://twistedmatrix.com/trac/

The learning curve of twisted is rather brutal,
NACK, the tutorial is -- IMHO -- rather easy if you are used to
writing Python code and doing asynchronous programming.

<http://twistedmatrix.com/projects/co...ntation/howto/
tutorial/index.html>
but it will do everything you want and a whole lot more!
That's true. More Twisted, less work (and less headache). IMHO.

Regards,
Björn

--
BOFH excuse #242:

Software uses US measurements, but the OS is in metric...

May 14 '07 #5

P: n/a
Paul Kozik wrote:
I am working on the networking code for a small Multiplayer RPG I'm
working on. I currently have some basic code using threads, but it
seems like asyncore would be far better suited for my needs. However,
I have trouble finding a solid example for what I need. Python.org and
other sites provide simple examples, but they appear more intended for
servers that simply send one peice of data to the client.
Here is a sample that combines asyncore/asynchat, wxPython, and optional
threads:
http://thread.gmane.org/gmane.comp.p...15/focus=47326

You can pull out the async subclasses and use them as a general Python
object transfer mechanism.

If you have specific asyncore/asynchat questions, email me directly and
I will try to help you.

- Josiah
May 17 '07 #6

P: n/a
On 14 Mag, 06:51, "Paul Kozik" <zyk...@gmail.comwrote:
I have trouble finding a solid example for what I need. Python.org and
other sites provide simple examples, but they appear more intended for
servers that simply send one peice of data to the client.
Not a big deal. asynchat / asyncore are pretty easy-to-learn
frameworks. Under the hoods they are extremely simpler if compared to
Twisted.
You shouldn't have problems in learning how the things works in a
couple of days.
Try to take a look at:
http://effbot.org/zone/asyncore-ftp-client.htm
http://effbot.org/librarybook/asynchat.htm
Besides this I am also stuck with dealing with TCP data streams. I can
receive and send the data (using threads, not yet with asynocore), but
I am unsure how to deal with the streamlike nature of TCP (and would
prefer to use TCP over UDP).
If you really need speed UDP could be a better choice.
While basic socket work was rather easy to deal with, this has proved
significantly more difficult.
Developing a bug-less network application by using the basic socket
module instead of an high-level framework like asyncore it's surely a
lot harder.
Again: asyncore is really simple: it's just a matter of understanding
the event-based approach that's very different from the thread-based
one.

May 17 '07 #7

P: n/a
On 14 Mag, 06:51, "Paul Kozik" <zyk...@gmail.comwrote:
I have trouble finding a solid example for what I need. Python.org and
other sites provide simple examples, but they appear more intended for
servers that simply send one peice of data to the client.
Not a big deal. asynchat / asyncore are pretty easy-to-learn
frameworks. Under the hoods they are extremely simpler if compared to
Twisted.
You shouldn't have problems in learning how the things works in a
couple of days.
Try to take a look at:
http://effbot.org/zone/asyncore-ftp-client.htm
http://effbot.org/librarybook/asynchat.htm
Besides this I am also stuck with dealing with TCP data streams. I can
receive and send the data (using threads, not yet with asynocore), but
I am unsure how to deal with the streamlike nature of TCP (and would
prefer to use TCP over UDP).
If you really need speed UDP could be a better choice.
While basic socket work was rather easy to deal with, this has proved
significantly more difficult.
Developing a bug-less network application by using the basic socket
module instead of an high-level framework like asyncore it's surely a
lot harder.
Again: asyncore is really simple: it's just a matter of understanding
the event-based approach that's very different from the thread-based
one.

May 17 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.