An asyncio example

Adam Bartoš drekin at gmail.com
Fri Jul 3 22:30:47 CEST 2015


>> Marko Rauhamaa:
>>> socket.shutdown(socket.SHUT_WR) does the trick.
>>>
>>> I think the asyncio.StreamWriter.write_eof() is the high-level
>>> equivalent.
>>
>> You are right that writer.write_eof() behaves like
>> writer.transport.get_extra_info("socket").shutdown(socket.SHUT_WR) –
>> the server resumes and sends the response. However, the client still
>> reads empty bytes afterwards.
>
> Reading empty bytes means the peer has shut down its end of the
> connection.

But it didn't or had sent a response before. My code suppose to be like
this:
1) The client sends a request message.
2) The client closes the writing direction of the socket.
3) The server reads the request message.
4) The server sends a response message and possibly closes the other
direction of the socket.
5) The client reads data – it should read the response sent by the server
but gets empty bytes instead.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150703/180985d0/attachment.html>


More information about the Python-list mailing list