Skip to content

Commit

Permalink
tcp endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Sep 24, 2015
1 parent d84dde2 commit cc5720e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{lib_dirs,[".."]}.
{deps_dir,["deps"]}.
{deps,[
{nitro, ".*", {git, "git://github.com/synrc/nitro.git", {tag,"master"}}},
{nitro, ".*", {git, "git://github.com/synrc/nitro.git", {tag,"0.9"}}},
{jsone, ".*", {git, "git://github.com/sile/jsone.git", {tag,"v0.3.3"}}},
{cowboy, ".*", {git, "git://github.com/extend/cowboy", {tag,"1.0.1"}}},
{gproc, ".*", {git, "git://github.com/uwiger/gproc.git", {tag,"0.3"}}}
Expand Down
4 changes: 2 additions & 2 deletions samples/apps/review/src/config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ log_level() -> info.
log_modules() -> % any
[
login,
wf_convert,
n2o_file,
% wf_convert,
% n2o_file,
n2o_async,
n2o_proto,
n2o_client,
Expand Down
20 changes: 20 additions & 0 deletions src/endpoints/n2o_relay.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-module(n2o_relay).
-description('N2O TCP relay endpoint handler').
-compile(export_all).

connect(IP, PortNo) ->
{ok, Socket} = gen_tcp:connect(IP, PortNo, [{active, false}, {packet, 2}]),
spawn(fun() -> recv(Socket) end),
Socket.

send(Socket, Message) ->
BinMsg = term_to_binary(Message),
gen_tcp:send(Socket, BinMsg).

recv(Socket) ->
{ok, A} = gen_tcp:recv(Socket, 0),
io:format("Received: ~p~n", [A]),
recv(Socket).

disconnect(Socket) ->
gen_tcp:close(Socket).

0 comments on commit cc5720e

Please sign in to comment.