socket.recvfrom() & sendto()
ron.l.johnson at home.com
Wed May 9 00:43:27 EDT 2001
Van Gale wrote:
> "Ron Johnson" <ron.l.johnson at home.com> wrote:
>> Since the server can send messages to the client at random and
>> irregular interevals, how can the client accept input from the
>> user at the same time that it is "stalled" at a select() ?
>> The server side I think I understand, at least from the perspective
>> of *my* needs: the server sits at a select() until it detects (an)
>> incoming message(s) from client(s); it then processes the message,
>> sends messages back to the sending client(s) and also possibly other
>> clients, then goes back to the select().
> I think you are understanding the server side correctly, and there's
> plenty of server applications in the Medusa package to use as a base for
> server. One minor point though, the "sending back to the clients" is also
> done through the select. Data being sent out from one of your connection
> objects sits in a buffer and is sent out in chunks each time the select on
> the socket says "ready to send".
> As for the client side, you will need to structure the code in a different
> way. It depends more on what GUI package you are using (wxPython?, wxQt?,
> tkinter?) than how the server is structured. You might need to use
> threads, e.g. a thread handling GUI stuff and another thread handling
> with the server. However you end up coding it, you DON'T want
> communications with the server to block GUI events.
> Look at rpc_client.py in Medusa for an example of coding an asynchat
> (although this doesn't do any GUI stuff). I haven't looked at any of the
> Python games out there to see if any of them would make a good starting
> point (even though I'm in the game development business<grin>), but I'd
> bet you could find some good starting code there as well.
Great. It's all coming into place now.
Medusa Medusa in 1 thread
user IO in another thread
(If u are a game writer, can u tell me if I am going about this
Ron Johnson, Jr. Home: ron.l.johnson at home.com
Jefferson, LA USA http://ronandheather.dhs.org
"Is Python better or worse than Perl?"
"Perl is worse than Python because people wanted it
worse." -Larry Wall, 10/14/1998
More information about the Python-list