Determine sockets in use by python

J

Jim Mellander

Hi:

I'm a newbie to python, although not to programming. Briefly, I am
using a binding to an external library used for communication in a
client-server context, with the server in python. Typically, I would
set this up with event callbacks, and then enter a select loop, which,
most the time idles and processes input events when the socket shows
activity, kinda like:

while True:
socket.select((my_socket),(),())
process_event()

Unfortunately, the API does not expose the socket to the script level,
and the developer recommends a busy loop:

while True:
sleep(1)
process_event()

which I hope to avoid, for many reasons. If the socket can be exposed
to the script level, then the problem would be solved.

Failing that, it would be nice to be able to pythonically determine
the sockets in use and select on those. Does anyone have any
suggestions on how to proceed?

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top