docs: public void serve() throws IOException {
  
          ServerSocket serverSocket = new ServerSocket(port);
          while (true) {
              try {
                  final Socket socket = serverSocket.accept();
  
                  Thread thread = new Thread("EnvServerSocketHandler") {
                      public void run() {
                          boolean running = false;
                          try {
                              checkHello(socket);
  
                              while (true) {
                                  DataInputStream din = new DataInputStream(socket.getInputStream());
                                  int hdr = din.readInt();
                                  byte[] data = new byte[hdr];
                                  din.readFully(data);
  
                                  String command = new String(data, utf8);
  
                                  if (command.startsWith("<Step")) {
  
                                      step(command, socket, din);
  
                                  } else if (command.startsWith("<Peek")) {
  
                                      peek(command, socket, din);
  
                                  } else if (command.startsWith("<Init")) {
  
                                      init(command, socket);
  
                                  } else if (command.startsWith("<Find")) {
  
                                      find(command, socket);
  
                                  } else if (command.startsWith("<MissionInit")) {
  
                                      if (missionInit(din, command, socket))
                                          running = true;
  
                                  } else if (command.startsWith("<Quit")) {
  
                                      quit(command, socket);
  
                                  } else if (command.startsWith("<Exit")) {
  
                                      exit(command, socket);
  
                                  } else if (command.startsWith("<Close")) {
  
                                      close(command, socket);
  
                                  }  else if (command.startsWith("<Status")) {
  
                                      status(command, socket);
  
                                  } else if (command.startsWith("<Echo")) {
                                      command = "<Echo>" + command + "</Echo>";
                                      data = command.getBytes(utf8);
                                      hdr = data.length;
  
                                      DataOutputStream dout = new DataOutputStream(socket.getOutputStream());
                                      dout.writeInt(hdr);
                                      dout.write(data, 0, hdr);
                                      dout.flush();
                                  } else {
                                      throw new IOException("Unknown env service command");
                                  }
                              }
                          } catch (IOException ioe) {
                              TCPUtils.Log(Level.SEVERE, "MalmoEnv socket error: " + ioe + " (can be on disconnect)");
                              try {
                                  if (running) {
                                      TCPUtils.Log(Level.INFO,"Want to quit on disconnect.");
                                      setWantToQuit();
                                  }
                                  socket.close();
                              } catch (IOException ioe2) {
                              }
                          }
                      }
                  };
                  thread.start();
              } catch (IOException ioe) {
                  TCPUtils.Log(Level.SEVERE, "MalmoEnv service exits on " + ioe);
              }
          }
      }