public static void main (String[] args) throws IOException, InterruptedException {
		final int port = 7000;
		final int writeBufferSize = 16384;
		final int objectBufferSize = 2048;
		final AtomicBoolean received = new AtomicBoolean();

		// Creating server
		final Server server = new Server(writeBufferSize, objectBufferSize);
		server.bind(port);
		server.start();
		System.out.println("Server listening on port " + port);

		// Creating client
		final Client client = new Client(writeBufferSize, objectBufferSize);
		client.start();
		client.addListener(new Listener() {
			@Override
			public void received (Connection connection, Object object) {
				if (object instanceof String) {
					System.out.println("Received: " + object);
					received.set(true);
				} else
					System.err.println("Received unexpected object");
			}
		});
		client.connect(5000, "localhost", port);
		System.out.println("Client connected");

		// Catching exception
		Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
			@Override
			public void uncaughtException (Thread t, Throwable e) {
				e.printStackTrace();
				received.set(true);
				// Stopping it all
				System.out.println("Stopping client and server");
				client.stop();
				server.stop();
			}
		});

		// Sending small messages
		for (int i = 0; i < 5; i++) {
			String smallMessage = "RandomStringUtils.randomAlphanumeric(256)";
			System.out.println("Sending: " + smallMessage);
			received.set(false);
			server.sendToAllTCP(smallMessage);
			while (!received.get()) {
				Thread.sleep(100);
			}
		}

		// Sending large message
		String bigMessage = "RandomStringUtils.randomAlphanumeric(532)RandomStringUtils.randomAlphanumeric(532)RandomStringUtils.randomAlphanumeric(532)RandomStringUtils.randomAlphanumeric(532)RandomStringUtils.randomAlphanumeric(532)RandomStringUtils.randomAlphanumeric(532)RandomStringUtils.randomAlphanumeric(532)";
		bigMessage = bigMessage + bigMessage + bigMessage + bigMessage + bigMessage + bigMessage + bigMessage;
		System.out.println("Sending: " + bigMessage);
		received.set(false);
		server.sendToAllTCP(bigMessage);
		while (!received.get()) {
			Thread.sleep(100);
		}
	}