Asyncore Help?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Kozik

    #1

    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?
  • Erik Max Francis

    #2
    Re: Asyncore Help?

    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:




    --
    Erik Max Francis && max@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

    Comment

    • Nick Craig-Wood

      #3
      Re: Asyncore Help?

      Erik Max Francis <max@alcyone.co mwrote:
      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.amk.ca/python/code/medusa.html
      There is also twisted of course if we are talking about async
      networking libraries.



      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 <nick@craig-wood.com-- http://www.craig-wood.com/nick

      Comment

      • Michael Bentley

        #4
        Re: Asyncore Help?


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

        Comment

        • Bjoern Schliessmann

          #5
          Re: Asyncore Help?

          Nick Craig-Wood wrote:

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

          Comment

          • Josiah Carlson

            #6
            Re: Asyncore Help?

            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:


            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

            Comment

            • billiejoex

              #7
              Re: Asyncore Help?

              On 14 Mag, 06:51, "Paul Kozik" <zyk...@gmail.c omwrote:
              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:


              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.

              Comment

              • billiejoex

                #8
                Re: Asyncore Help?

                On 14 Mag, 06:51, "Paul Kozik" <zyk...@gmail.c omwrote:
                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:


                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.

                Comment

                Working...