about network module

huzhenghui37 wrote:

well, i know there are some modules about network, socket for instance.
and i know that there are also some mudules about network in wxPython's frameworks.
what's the difference? i am a newbie.

The wx.Socket* classes are not implemented in wxPython. I've actually taken a crack at implementing them, but thus far I have been totally dissatisfied with the results so I haven't shared them (mostly due to extreme embarassment).

Unfortunately, there is nothing in Pything that is an *exact* fit to the wx Socket classes, in that it lacks integration with the wx event loop. This essentially means that if you try talking to a socket within the wx context, you end up freezing up the GUI until the network events complete.

My solutions so far have involved worker threads and the select Python module. This works great but there is a problem communicating the data back to the wx event loop.

In 2.5.1, however, we have wx.CallLater() which takes whatever function you want and places the call to it onto the wx event loop with no fuss. With this, all we need to do is establish some callbacks in the main app and we're set.

In theory, of course. I haven't had a chance to go back to my code and try to implement it yet :slight_smile:

Note: I *have* gotten the basics to work just fine, just not in a form that is acceptable in a library. It works, and works great, but it is not ready for Joe Average wx.Programmer to use yet. I don't want to imply that it doesn't work, and work well.

Note2: No doubt somebody will say "just use twisted." Well, it works. No futher comment :slight_smile: