public synchronized void close() throws IOException {
		if (serverSocket != null) {
			if (this.listening) {
				closing = true;

				for (int i = clients.size() - 1; i >= 0; --i)
					clients.get(i).close();

				Thread.yield();

				while (clients.size() > 0) {
					Thread.yield();

					try {
						Thread.sleep(50);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}

					Thread.yield();
				}

				if (acceptThread != null) {
					acceptThread.interrupt();
					acceptThread = null;
				}

				this.listening = false;

				serverSocket.close();

				Thread.yield();
			}
		}

		this.listening = false;
	}