System.out.println("Accepted connection from " + ia.getHostAddress() + " " + ia.getHostName());
System.out.println(new Date() + " Accepted connection from " + ia.getHostAddress() + " " + ia.getHostName());
  public void process(Socket socket) {    InetAddress ia = socket.getInetAddress();    System.out.println("Accepted connection from " + ia.getHostAddress() + " " + ia.getHostName());    InputStream is = null;    OutputStream os = null;    try {      socket.setSoTimeout(socketTimeoutMs);            is = socket.getInputStream();      os = socket.getOutputStream();      String headers[] = getHeaders(is);      byte[] buf = new byte[getContentLength(headers)];      int pos = 0;      while (pos < buf.length) {        int nbytes = is.read(buf, pos, buf.length - pos);        if (nbytes < 0)          throw new IOException("Content truncated");        pos += nbytes;      }      //      System.out.println("Request:");//      System.out.println(new String(buf));            ServerDatabase request = new ServerDatabase(new ByteArrayInputStream(buf));      ServerDatabase reply = masterDatabase.processRequest(request);//      System.out.println("Reply:");//      System.out.println(reply.toString());      os.write(reply.toString().getBytes());    }    catch (Exception e) {      e.printStackTrace(System.out);    }    finally {      if (is != null) try { is.close(); } catch (IOException e) { e.printStackTrace(); }      if (os != null) try { os.close(); } catch (IOException e) { e.printStackTrace(); }      System.out.println();    }  }