aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/net
diff options
context:
space:
mode:
Diffstat (limited to 'shard/lib/net')
-rw-r--r--shard/lib/net/tcpconn.ex4
-rw-r--r--shard/lib/net/tcpserver.ex7
2 files changed, 6 insertions, 5 deletions
diff --git a/shard/lib/net/tcpconn.ex b/shard/lib/net/tcpconn.ex
index 5dbf42b..67d7f4c 100644
--- a/shard/lib/net/tcpconn.ex
+++ b/shard/lib/net/tcpconn.ex
@@ -147,7 +147,7 @@ defmodule SNet.TCPConn do
{:ok, {addr, port}} = :inet.peername socket
state = stream_param
|> Map.put(:socket, socket)
- |> Map.put(:peer_info, {:tcp4, addr, port})
+ |> Map.put(:peer_info, {:inet, addr, port})
|> Map.put(:my_port, state.my_port)
GenServer.cast(Shard.Manager, {:peer_up, self(), state.peer_info, state.auth})
@@ -259,7 +259,7 @@ defmodule SNet.TCPConn do
{:ok, {addr, port}} = :inet.peername socket
state = stream_param
|> Map.put(:socket, socket)
- |> Map.put(:peer_info, {:tcp4, addr, his_port})
+ |> Map.put(:peer_info, {:inet, addr, his_port})
|> Map.put(:my_port, state.my_port)
GenServer.cast(Shard.Manager, {:peer_up, self(), state.peer_info, state.auth})
diff --git a/shard/lib/net/tcpserver.ex b/shard/lib/net/tcpserver.ex
index 1aa5738..6cc3473 100644
--- a/shard/lib/net/tcpserver.ex
+++ b/shard/lib/net/tcpserver.ex
@@ -2,14 +2,15 @@ defmodule SNet.TCPServer do
require Logger
use Task, restart: :permanent
- def start_link(port) do
- Task.start_link(__MODULE__, :accept, [port])
+ def start_link(_) do
+ Task.start_link(__MODULE__, :accept, [])
end
@doc """
Starts accepting connections on the given `port`.
"""
- def accept(port) do
+ def accept() do
+ port = Application.get_env(:shard, :port)
{:ok, socket} = :gen_tcp.listen(port,
[:binary, packet: 2, active: false, reuseaddr: true])
Logger.info "Accepting connections on port #{port}"