Socket Programming

Discussion in 'Python' started by srinivasan srinivas, Jun 14, 2008.

  1. srinivasan srinivas, Jun 14, 2008
    #1
    1. Advertising

  2. srinivasan srinivas

    Jeff McNeil Guest

    On Jun 14, 5:38 pm, srinivasan srinivas <>
    wrote:
    > Hi,
    > Is there any way(method) to find whether the socket got closed or not??
    > Thanks,
    > Srini
    >
    >       Best Jokes, Best Friends, Best Food and more. Go tohttp://in.promos.yahoo.com/groups/bestofyahoo/



    That's slightly difficult to answer without knowing any context. Do
    you want to know if the other end has closed the connection?
    Assuming that's the case and you're just using the standard socket
    library, it's largely the same as it would be should you do it in C.
    A TCP socket with a closed peer will select as 'ready' for read. When
    you attempt to read that socket, you'll have a 0 length return.

    If you attempt to write to a socket that's been closed by the other
    end, you ought to receive a "Broken pipe' socket error. If you
    attempt to write to a socket that *you've* already closed, then you
    should just get a standard 'Bad file descriptor' socket.error.

    Google's your friend with topics like this. There's a lot out there
    pertaining to the standard POSIX socket calls.
     
    Jeff McNeil, Jun 15, 2008
    #2
    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. Laszlo Nagy
    Replies:
    1
    Views:
    5,090
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    1,027
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    594
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    711
    Steve Holden
    Feb 1, 2009
  5. Steve Holden
    Replies:
    1
    Views:
    756
Loading...

Share This Page