*
* The MIT License (MIT)
*
- * Copyright (C) 2016 Kevin Lamonte
+ * Copyright (C) 2017 Kevin Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* @param args Command line arguments
*/
public static void main(final String [] args) {
+ ServerSocket server = null;
try {
if (args.length == 0) {
System.err.printf("USAGE: java -cp jexer.jar jexer.demos.Demo2 port\n");
}
int port = Integer.parseInt(args[0]);
- ServerSocket server = new TelnetServerSocket(port);
+ server = new TelnetServerSocket(port);
while (true) {
Socket socket = server.accept();
System.out.printf("New connection: %s\n", socket);
}
} catch (Exception e) {
e.printStackTrace();
+ } finally {
+ if (server != null) {
+ try {
+ server.close();
+ } catch (Exception e) {
+ // SQUASH
+ }
+ }
}
}