[wxPython] Getting an event from a file descriptor

Hi -

I am using wxPython on Linux. I have some underlying classes which open
a Unix domain socket (a local socket, not Ethernet or IP). I want to
be notified when there is input on the socket. I do not want to rewrite
my communication classes to require wxPython; most executables I create in
this environment do not require a GUI. For most of the executables, I just
use select(). Up to now, the GUI I have been using has an analog to
XtAddInput, any file descriptor can be monitored.

I assume that in EVT_SOCKET(id, func), the id is not a file descriptor, but
requires that the socket have been created through wxWindows.

Is there any way to monitor input based on just a file descriptor?

Thanks.

- BOB

Robert George Mayer wrote:

I am using wxPython on Linux. I have some underlying classes which open
a Unix domain socket (a local socket, not Ethernet or IP). I want to
be notified when there is input on the socket. I do not want to rewrite
my communication classes to require wxPython; most executables I create in
this environment do not require a GUI. For most of the executables, I just
use select(). Up to now, the GUI I have been using has an analog to
XtAddInput, any file descriptor can be monitored.

It's not easy to do this in a portable manner so it the capability is not in wxWindows.

I assume that in EVT_SOCKET(id, func), the id is not a file descriptor, but
requires that the socket have been created through wxWindows.

Yes, but wxPython doesn't wrap wxSocket so it doesn't matter.

Is there any way to monitor input based on just a file descriptor?

I would run a select() loop in an alternate thread and then send custom events to the GUI thread, or use one of the other inter-thread communication mechanisms that have been discussed here before.

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!