Found the solution, The correct solution is:
Not this:
Socket ServerSok = new Socket(String host,int port);
ServerSok.close();
But this:
ServerSocket socket = new ServerSocket(1066);
while (true) {
Socket connection = socket.accept();
connection.close();
}