Skip to content

Commit

Permalink
Rename argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavisp3 committed Sep 23, 2010
1 parent 91100a7 commit 09e3988
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions erlang-client-1/get-poetry
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ collect_poems(N, Poems) ->
end.


peername(Sock) ->
{ok, {IP, Port}} = inet:peername(Sock),
peername(Socket) ->
{ok, {IP, Port}} = inet:peername(Socket),
format_ip(IP) ++ ":" ++ erlang:integer_to_list(Port).

format_ip(IP) when is_tuple(IP) ->
Expand All @@ -78,16 +78,16 @@ format_ip(IP) ->

get_poetry(Tasknum, Addr, Main) ->
{Host, Port} = Addr,
{ok, Sock} = gen_tcp:connect(Host, Port,
[binary, {active, false}, {packet, 0}]),
get_poetry(Tasknum, Sock, Main, []).
{ok, Socket} = gen_tcp:connect(Host, Port,
[binary, {active, false}, {packet, 0}]),
get_poetry(Tasknum, Socket, Main, []).

get_poetry(Tasknum, Sock, Main, Packets) ->
case gen_tcp:recv(Sock, 0) of
get_poetry(Tasknum, Socket, Main, Packets) ->
case gen_tcp:recv(Socket, 0) of
{ok, Packet} ->
io:format("Task ~w: got ~w bytes of poetry from ~s\n",
[Tasknum, size(Packet), peername(Sock)]),
get_poetry(Tasknum, Sock, Main, [Packet|Packets]);
[Tasknum, size(Packet), peername(Socket)]),
get_poetry(Tasknum, Socket, Main, [Packet|Packets]);
{error, _} ->
Main ! {poem, list_to_binary(lists:reverse(Packets))}
end.
Expand Down

0 comments on commit 09e3988

Please sign in to comment.