tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: readv() on TCP socket returns 0



"James K. Lowden" <jklowden%schemamania.org@localhost> wrote:
 |On Fri, 08 Mar 2013 12:21:45 +0100
 |Steffen "Daode" Nurpmeso <sdaoden%gmail.com@localhost> wrote:
 |>|Are you saying you can't half-close a TCP connection on OS X?  I am
 |>|skeptical.
 |> 
 |> And you're damn right, that must have been a Python bug that i've
 |> seen back in 2011, and even implemented a workaround for (after
 |> painful debugging)!
 |
 |The OS X manual is pretty clear on the point, 
 |
 |      "The shutdown() call causes all or part of a full-duplex
 |connection on the socket associated with socket to be shut down.  If
 |how is SHUT_RD, further receives will be disallowed.  If how is
 |SHUT_WR, further sends will be disallowed.  If how is SHUT_RDWR,
 |further sends and receives will be disallowed." 

My response comes late since this thread made me wonder wether
i've really debugged my shutdown() usage just as i'd written, or
wether i blindly trusted the Python (though Python!)
documentation.  Also because only one commit covers the shutdown
handling.

So, with Python and enabled shutdown on Mac OS X Snow Leopard
i get this:

  # pop.gmail.com/173.194.78.108:995: recv_okline: b'+OK Welcome.'
  # pop.gmail.com/173.194.78.108:995: send_line(shut:False): 'LIST'
  recv_into len: 29
  # pop.gmail.com/173.194.78.108:995: recv_okline: b'+OK 0 messages (0 bytes)'
  # pop.gmail.com/173.194.78.108:995: recv_multiline: receiving message content
  - pop.gmail.com:INBOX: 0 messages (0 bytes) [seen]
  # pop.gmail.com/173.194.78.108:995: send_line(shut:True): 'QUIT'
  GOING TO RECEIVE OK AFTER SHUTDOWN
  recv_into len: 0
  SHUTTED DOWN

So, with Python, no more +OK line can be read after a call to

  self._sock.shutdown(Loader.socket.SHUT_WR)

 |--jkl

With a huge snake blues,

--steffen


Home | Main Index | Thread Index | Old Index