I'm learning about sockets in java. I was able to connect a client socket to an online server, but I can connect them to my own server socket!
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
class Blargh2 {
public static void main(String[] args) {
Socket client = null;
ServerSocket server = null;
System.out.println("Line one reacehd!");
try {
server = new ServerSocket(4445);
} catch (Exception e) {
System.out.println("Error:" + e.getMessage());
}
System.out.println("Line two reacehd!");
try {
client = server.accept();
} catch (IOException e) {
System.out.println("Accept failed: 4444");
System.exit(-1);
}
System.out.println("Line three reacehd!");
try {
server.close();
client.close();
} catch (IOException e) {
System.out.println("Accept failed: 4444");
System.exit(-1);
}
}
}
The program reaches lines one and two but it never reaches line 3! Can anyone help me solve this? Firewall also allows this connection...