Fixed wrong exception catching

This commit is contained in:
Marcin Kostrzewski 2020-10-28 18:00:36 +01:00
parent 1ac0d97ce7
commit f296770a21

View File

@ -8,6 +8,7 @@ import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.ConnectException;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -43,7 +44,7 @@ public class Connection {
public Connection(String address) throws IOException { public Connection(String address) throws IOException {
try { try {
connectAsClient(address); connectAsClient(address);
} catch (UnknownHostException e) { } catch (ConnectException e) {
makeServer(); makeServer();
} }
out = new PrintWriter(clientSocket.getOutputStream(), true); out = new PrintWriter(clientSocket.getOutputStream(), true);