code: public void start() {
          try {
              while (keepGoing) {
                  try {
                      // this is a blocking call so it hogs a thread
                      final Socket socket = ss.accept();
                      final String socketName = socket.getInetAddress().getHostAddress() + ":"
                              + socket.getPort();
                      log.info("accepted socket connection from " + socketName);
                      try {
                          final OutputStream out = socket.getOutputStream();
  
                          Subscriber<String> subscriber = createSubscriber(socket, socketName, out);
                          subscriptions.add(subscriber);
                          source.subscribeOn(Schedulers.io())
                                  // remove subscriber from subscriptions on unsub
                                  .doOnUnsubscribe(() -> subscriptions.remove(subscriber))
                                  // write each line to the socket OutputStream
                                  .subscribe(subscriber);
  
                      } catch (IOException e) {
                          // could not get output stream (could have closed very
                          // quickly after connecting)
                          // dont' care
                          log.warn(e.getClass().getSimpleName() + ": " + e.getMessage());
                      }
                  } catch (SocketTimeoutException e) {
                      // don't care
                      log.warn(e.getClass().getSimpleName() + ": " + e.getMessage());
                  }
              }
          } catch (IOException e) {
              if (keepGoing) {
                  log.warn(e.getMessage(), e);
                  throw new RuntimeException(e);
              } else
                  log.info("server stopped");
          } finally {
              closeServerSocket();
          }
      }
docs: Starts the server. Each connection to the server will bring about another
  subscription to the source.