Skip to content

Commit

Permalink
print error message when port cannot be opened
Browse files Browse the repository at this point in the history
  • Loading branch information
beidouz committed Dec 6, 2018
1 parent 2059fb3 commit 579c3f4
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions modP2pImpl/src/org/aion/p2p/impl1/P2pMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,23 @@ public void run() {
* Bigger RECV_BUFFER and BACKLOG can have a better socket read/write tolerance, can be a advanced p2p settings in the config file.
*/
tcpServer.socket().setReceiveBufferSize(SOCKET_RECV_BUFFER);
tcpServer
.socket()
.bind(
new InetSocketAddress(Node.ipBytesToStr(selfIp), selfPort),
SOCKET_BACKLOG);

try {
tcpServer
.socket()
.bind(
new InetSocketAddress(Node.ipBytesToStr(selfIp), selfPort),
SOCKET_BACKLOG);
} catch (IOException e) {
p2pLOG.error(
"Failed to connect to Socket Address: "
+ Node.ipBytesToStr(selfIp)
+ ":"
+ selfPort
+ ", please check your ip and port configration!",
e);
}

tcpServer.register(selector, SelectionKey.OP_ACCEPT);

Thread thrdIn = new Thread(getInboundInstance(), "p2p-in");
Expand Down

0 comments on commit 579c3f4

Please sign in to comment.