Why not have a recvall method?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Feb 4 08:31:27 EST 2018


On Sun, 04 Feb 2018 19:26:36 +0800, 陶青云 wrote:

> Hello, allThe socket object has a `sendall` method that can send all
> bytes you specified. Oppositely, socket only has a recv method. I wonder
> why there is not a `recvall` method? To workaround this, I use `f =
> socket.makefile('rb')`, then `call f.read(n)` Thanks.

I am not an expert on sockets, but since f.read(n) will read a maximum of 
n bytes, isn't that the same as socket_obj.recv(n)?



-- 
Steve




More information about the Python-list mailing list