@Override
	public void execute() {

		Socket s = null;
		try {
			while (!stop && !runningThread.isInterrupted()) {
				try {
					s = serverSocket.accept();
				} catch (SocketException se) {
					log.info("Received a shutdown request: " + se);
					stop = true;
				} catch (IOException ioe) {
					log.error("IO-error while waiting for new socket connection.", ioe); 
					// TODO: Check if server-socket should be restarted, see also
					// http://stackoverflow.com/questions/3028543/what-to-do-when-serversocket-throws-ioexception-and-keeping-server-running
				}
				if (s == null) continue;
				socketExchanger.offer(s);
				s = null;
			}
		} catch (InterruptedException ie) {
			// Can happen when socketExchanger.offer(s) is blocking.
			log.info("Socket server interrupted.");
		} catch (Throwable t) {
			// Should this be fatal?
			log.error("Unexpected error encountered, socket server stopping!", t);
			runtimeError = t;
		} finally {
			closeServerSocket();
			// if an InterruptedException occurred a new socket might have been left dangling.
			closeSocket(s);
			socketExchanger.close();
			if (exitOnError && runtimeError != null) {
				runningThread = null;
				System.exit(1);
			}
		}
	}