Re: Newbie question: SOLVED (how to keep a socket listening),but still some questions

Discussion in 'Python' started by Jp Calderone, Jun 25, 2005.

  1. Jp Calderone

    Jp Calderone Guest

    On Sat, 25 Jun 2005 01:36:56 -0000, Grant Edwards <> wrote:
    >On 2005-06-25, Giovanni Tumiati <> wrote:
    >
    >> (2)Does one have to do a socket.shutdown() before one does a
    >> socket.close??

    >
    >No.
    >
    >[I've never figured out why one would do a shutdown RDWR
    >rather than close the connection, but I haven't put a lot of
    >thought into it.]


    shutdown actually tears down the TCP connection; close releases the file descriptor.

    If there is only one file descriptor referring to the TCP connection, these are more or less the same. If there is more than one file descriptor, though, the difference should be apparent.

    Jp
     
    Jp Calderone, Jun 25, 2005
    #1
    1. Advertising

  2. Jp Calderone

    pwilkins Guest

    Re: Newbie question: SOLVED (how to keep a socket listening), but still some questions

    On Fri, 24 Jun 2005 21:42:48 -0400, Jp Calderone wrote:


    > shutdown actually tears down the TCP connection; close releases the file
    > descriptor.
    >
    > If there is only one file descriptor referring to the TCP connection,
    > these are more or less the same. If there is more than one file
    > descriptor, though, the difference should be apparent.
    >
    > Jp



    Yes I think you are right. I checked with the "Socket Programming HOWTO"
    by Gordon McMillan @ http://www.python.org/doc/howto.

    Here's a quote:
    "Strictly speaking, you're supposed to use shutdown on a socket before you
    close it. The shutdown is an advisory to the socket at the other end.
    Depending on the argument you pass it, it can mean "I'm not going to send
    anymore, but I'll still listen", or "I'm not listening, good riddance!".
    Most socket libraries, however, are so used to programmers neglecting to
    use this piece of etiquette that normally a close is the same as
    shutdown(); close(). So in most situations, an explicit shutdown is not
    needed."

    However my first understanding from the python docs is quite different..
    it was that like a unix pipe, a socket could be made to communicate in one
    direction only. Like a RD-only pipe a socket could be made RD-only and
    another socket WR-only...perhaps like ftp keeps the control channel open
    but transmits over a read only socket???
     
    pwilkins, Jun 25, 2005
    #2
    1. Advertising

  3. Re: Newbie question: SOLVED (how to keep a socket listening), but still some questions

    On 2005-06-25, Jp Calderone <> wrote:

    >>[I've never figured out why one would do a shutdown RDWR rather
    >>than close the connection, but I haven't put a lot of thought
    >>into it.]

    >
    > shutdown actually tears down the TCP connection; close
    > releases the file descriptor.
    >
    > If there is only one file descriptor referring to the TCP
    > connection, these are more or less the same. If there is more
    > than one file descriptor, though, the difference should be
    > apparent.


    Ah yes. I hadn't thought of that. I think the only time I had
    ever used shutdown was to shutdown just the transmit half.

    --
    Grant Edwards grante Yow! An INK-LING? Sure --
    at TAKE one!! Did you BUY any
    visi.com COMMUNIST UNIFORMS??
     
    Grant Edwards, Jun 25, 2005
    #3
    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. pwilkins
    Replies:
    7
    Views:
    474
    Grant Edwards
    Jun 25, 2005
  2. Giovanni Tumiati
    Replies:
    2
    Views:
    345
    Grant Edwards
    Jun 25, 2005
  3. Jp Calderone
    Replies:
    1
    Views:
    351
    Grant Edwards
    Jun 25, 2005
  4. Michael Bacarella
    Replies:
    26
    Views:
    1,390
    harri
    Nov 20, 2007
  5. hisan
    Replies:
    1
    Views:
    1,372
    Dan Stromberg
    Jun 25, 2012
Loading...

Share This Page