gen_tcp bug ?

Bengt Kleberg <>
Mon Jun 13 11:07:33 CEST 2005


On 2005-06-10 15:38, Claes Wikstrom wrote:
> 
> Is This a bug ? I surely consider it weird and unexpected.
> 
> Run a:srv() in one shell and then a:cli() in another?
> 
> I'd expect the call to gen_tcp:recv(Fd, 100) to return
> {ok, Bin} where size(Bin) == 50 in the second call. That is
> how unix read() works. As it is now, it's not good and severely
> violates the "principle of least surprise"

i think it depends upon how much c programming one has been subjected 
to. since there is no receive buffer that can be filled, the length is 
no longer a maximum limit. it is a ''this amount and no other'' request. 
if it returns successfully a non-c programmer would(should?) be very 
surprised if it has read less than length bytes. therefore {error, 
closed} is ok.

i am happy with any one of both behaviours. ie, the current behaviour or 
the c like behaviour.

perhaps {error, closed, Bin} would be a suitable compromise?


bengt



More information about the erlang-questions mailing list