@Override
	public void executeTask() {
		waitForDefaultGateway();
		String defGateway = DCServer.GetDefaultGateway();

		System.out.println("=====================================");
		System.out.println("Looking for server");
		System.out.println("Default gateway: " + defGateway);
		System.out.println("=====================================");

		int count = 0;

		do {
			try {
				dataGramSocket = new DatagramSocket(MY_PORT);
				dataGramSocket.setBroadcast(true);
				dataGramSocket.setReuseAddress(true);
				dataGramSocket.setSoTimeout(5);
			} catch (SocketException e) {
				MY_PORT = MY_PORT + 100;
				executeTask();
				e.printStackTrace();
			}

			byte[] buf = new byte[1024];
			DatagramPacket receivedPacket = new DatagramPacket(buf, buf.length);
			DatagramPacket sendingPacket;

			String ipPiece = defGateway.substring(0, defGateway.length() - 1);

			String[] ipPieces = defGateway.split("\\.");

			ipPiece = ipPieces[0] + "." + ipPieces[1] + ".";

			System.out.println("Scan: " + ++count);
			System.out.println("Scanning....");

			/*
			 * This is rather slow. Multithread this.
			 */

			for (int i = 0; i < 2; i++) {

				for (int j = 0; j < 255; j++) {

					String listeningPort = String.valueOf(MY_PORT);

					String toServerStr;
					try {
						toServerStr = (InetAddress.getLocalHost().getHostName()
								+ "|" + listeningPort);

						buf = toServerStr.getBytes();

						String builtIP = ipPiece + Integer.toString(i) + "."
								+ Integer.toString(j);

						// System.out.println("BUILT IP: " + builtIP);

						sendingPacket = new DatagramPacket(buf, buf.length,
								InetAddress.getByName(builtIP), 1337);
						dataGramSocket.send(sendingPacket);
						dataGramSocket.receive(receivedPacket);

						String localHost = InetAddress.getLocalHost()
								.getHostAddress();
						buf = localHost.getBytes();

						InetAddress address = receivedPacket.getAddress();
						String serverData = new String(receivedPacket.getData());

						String hostName = address.getHostName();

						serverData.substring(0, serverData.indexOf("|"));
						serverData.substring(serverData.indexOf("|") + 1,
								serverData.indexOf("|") + 5);

						System.out.println("Discovered server: " + hostName);
						// registerServer(new Server(serverAddress, hostName,
						// Integer.parseInt(serverPort)));

					} catch (SocketTimeoutException e) {

					} catch (UnknownHostException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}

				}

				// if ((i % 5) == 0) {
				// System.out.println("%" + ((i / 254.0) * 100));
				// }
			}

			dataGramSocket.close();

			String userOpt = SynchedInOut.getInstance()
					.postMessageForUserInput("Scan finished. Rescan? (y/n): ");

			if (userOpt.equalsIgnoreCase("y")) {
				executeTask();
			}

			else {
				stopTask();
			}

			// pauseServerDiscoveryTask();

		} while (isExecuting());

		stopTask();
	}