mysql_sock_tcp.erl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. %% MySQL/OTP – MySQL client library for Erlang/OTP
  2. %% Copyright (C) 2017 Piotr Nosek, Michal Slaski
  3. %%
  4. %% This file is part of MySQL/OTP.
  5. %%
  6. %% MySQL/OTP is free software: you can redistribute it and/or modify it under
  7. %% the terms of the GNU Lesser General Public License as published by the Free
  8. %% Software Foundation, either version 3 of the License, or (at your option)
  9. %% any later version.
  10. %%
  11. %% This program is distributed in the hope that it will be useful, but WITHOUT
  12. %% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. %% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. %% more details.
  15. %%
  16. %% You should have received a copy of the GNU Lesser General Public License
  17. %% along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. %% @doc This module provides TCP socket interface, i.e. is a proxy to gen_tcp and inet.
  19. %% @private
  20. -module(mysql_sock_tcp).
  21. -export([connect/3, close/1, send/2, recv/2, recv/3]).
  22. -export([setopts/2]).
  23. connect(Host, Port, SockOpts) ->
  24. gen_tcp:connect(Host, Port, SockOpts).
  25. close(Socket) ->
  26. gen_tcp:close(Socket).
  27. send(Socket, Packet) ->
  28. gen_tcp:send(Socket, Packet).
  29. recv(Socket, Length) ->
  30. gen_tcp:recv(Socket, Length).
  31. recv(Socket, Length, Timeout) ->
  32. gen_tcp:recv(Socket, Length, Timeout).
  33. setopts(Socket, SockOpts) ->
  34. inet:setopts(Socket, SockOpts).