Skip to content

Instantly share code, notes, and snippets.

@nox
Created October 20, 2010 09:34
Show Gist options
  • Save nox/636088 to your computer and use it in GitHub Desktop.
Save nox/636088 to your computer and use it in GitHub Desktop.
do_handshake(Socket, User, #connect_opts{passwd = Passwd, db = Db}) ->
{ok, {Number, Bytes}} = mysqerl_tcp:recv(Socket),
{Caps, Message} = mysqerl_util:read_init(Bytes),
ok = send_auth(Socket, Number + 1, User, Message, Passwd),
State = #state{socket = Socket, supports = Caps},
case Db of
undefined -> {ok, State};
_ ->
case do_use(Db, State) of
Error = {error, _Reason} -> {stop, Error};
_Ok -> {ok, State} end end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment