[erlang-questions] R14B gen_tcp:recv/2,3

Bengt Kleberg bengt.kleberg@REDACTED
Fri Sep 17 09:57:39 CEST 2010


One more thing. I hope you are not contemplating having different
versions of your code for different versions of the erlang VM.

If you code like this:

case gen_tcp:recv(Sock, Len, RecvTimeout)
of {ok, {http_error,String}} -> {error, Reason}
; {ok, Bin} -> {ok, Bin}
; {error, Reason} -> {error, Reason}
end.

it will work on both versions of the erlang VM.


bengt

On Fri, 2010-09-17 at 09:29 +0200, Roberto Ostinelli wrote:
> > Greetings,
> >
> > If (I have not read the document) gen_tcp:recv/2,3 returns {ok,
> > {http_error,String}} your have a matching clause. Unfortunately the
> > match means that Bin will be {http_error,String}, which is probably not
> > what you want.
> >
> 
> hi bengt,
> 
> my code was just making a statement and is indeed incorrect.
> 
> i do have quite some code which relies on {packet, http} and passive
> mode, so i believe i might be confronted with adding code which
> handles running on different versions of the erlang VM. *if* i'm
> not misunderstanding, this does break backwards compatibility and i'm
> quite surprised, to the point i'm asking this list for confirmation.
> 
> r.



More information about the erlang-questions mailing list