Sometimes the protocol is using simple integer number to describe what's going on. Let's have a look at the SMTP protocol:
2XX are ok codes,
5XX are error codes.
Testing Binary matching:
-module(bintest).
-export([test/0, check/1]).
test() ->
Bin = <<"200 OK\r\n">>,
check(Bin).
check(<<"200", Rest/binary>>) ->
{200, Rest};
check(<<"300", Rest/binary>>) ->
{300, Rest};
check(_Bin) ->
{800, unknown}.
No comments:
Post a Comment