Skip to content

Commit

Permalink
Fixed java.net.BindException
Browse files Browse the repository at this point in the history
  • Loading branch information
jgesc committed Mar 23, 2018
1 parent 4078ec3 commit e13b03d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Transfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,15 @@ private Socket host(int port) throws IOException {
// Wait for connection
serverSocket.setSoTimeout(timeout);
serverSocket.setReuseAddress(true);
Socket socket = serverSocket.accept();
// Close welcome socket as it is no longer needed
serverSocket.close();
Socket socket;
try {
socket = serverSocket.accept();
}
finally {
// Close welcome socket as it is no longer needed
serverSocket.close();
}

// Return connection socket
return socket;
}
Expand Down

0 comments on commit e13b03d

Please sign in to comment.