-
Notifications
You must be signed in to change notification settings - Fork 0
/
Robot.java
52 lines (46 loc) · 991 Bytes
/
Robot.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.io.IOException;
/**
* @author martin (cernama9@fit.cvut.cz)
* @since 6.3.15.
*/
/**
* The main Robot class. The Entry point of this application
*/
public final class Robot
{
/**
* Application entry point
*
* @param args Program arguments (namely the TCP port to listen on)
* @throws IOException
*/
public static void main(String[] args) throws IOException
{
if (args.length != 1)
{
System.err.println("Server: java robot.Robot <port>");
System.exit(1);
}
int port = 0;
try
{
port = Integer.parseInt(args[0]);
}
catch (NumberFormatException e)
{
System.err.println("Please specify the port as a correct number");
System.exit(2);
}
finally
{
if (port < 3000 || port > 3999)
{
System.err.println("Please specify a port within the range 3000 through 3999 (including)");
System.exit(3);
}
}
System.out.println("Starting server...\n");
Server server = new Server(port);
server.startServer();
}
}