473,401 Members | 2,068 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,401 software developers and data experts.

Asyncore Help?

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
7 2638
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
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

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

May 14 '07 #4
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Michael Welsh | last post by:
In order to learn sockets in Python I am trying to write a simple group chat server and client. I need a little nudge, please. My question contains some GUI but only as decoration. The root...
5
by: David M. Wilson | last post by:
Hi peeps, I finally got around recently to doing something serious using Python for serving network clients asynchronously, deciding on asyncore as my starting point. After 2 days or so of...
3
by: Anand Pillai | last post by:
This is for folks who are familiar with asynchronous event handling in Python using the asyncore module. If you have ever used the asyncore module, you will realize that it's event loop does not...
1
by: export | last post by:
Is there any tutorial and docs with samples how to use asyncore module? Thanks Lad
0
by: Tony Meyer | last post by:
Changes in asyncore from 2.3 to 2.4 mean that asyncore.poll() now passes all the sockets in the map to select.select() to be checked for errors, which is probably a good thing. If an error occurs,...
5
by: JamesHoward | last post by:
I have a problem with python's asyncore module throwing a bad file descriptor error. The code might be difficult to copy here, but the problem is essentially: The server wants to sever the...
2
by: Indy | last post by:
Greetings. I am writing an asynchronous server, and I use the standard library's module asyncore. I subclass asyncore.dispatcher. handle_accept works just right, that is, when a client socket...
7
by: billie | last post by:
Hi all. I've just terminated a server application using asyncore / asynchat frameworks. I wrote a test script that performs a lot of connections to the server app and I discovered that asyncore...
4
by: Giampaolo Rodola' | last post by:
Hi there. We're talking about an asyncore-based server. Just for the heck of it I'd like to set a timeout which will disconnects the clients if they're inactive (i.e., no command or data transfer...
0
by: Giampaolo Rodola' | last post by:
Hi, I post this message here in the hope someone using asyncore could review this. Since the thing I miss mostly in asyncore is a system for calling a function after a certain amount of time, I...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.