Determine sockets in use by python

Discussion in 'Python' started by Jim Mellander, Sep 29, 2010.

  1. 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
     
    Jim Mellander, Sep 29, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. billiejoex

    Closing programs that use sockets

    billiejoex, Aug 26, 2005, in forum: Python
    Replies:
    2
    Views:
    313
    billiejoex
    Aug 27, 2005
  2. Replies:
    2
    Views:
    314
    Gianni Mariani
    Oct 31, 2006
  3. Jim Mellander

    Re: Determine sockets in use by python

    Jim Mellander, Sep 29, 2010, in forum: Python
    Replies:
    4
    Views:
    247
    Antoine Pitrou
    Oct 1, 2010
  4. roni
    Replies:
    0
    Views:
    119
  5. Peña, Botp
    Replies:
    1
    Views:
    242
    Robert Klemme
    Jan 24, 2004
Loading...

Share This Page