src/main/java/pityoulish/sockets/server/SimplisticSocketHandler.java
protected void acceptAndServeRequest()
    throws Exception
  {
    Socket sock = srvSocket.accept();

    try {
      // Of course it makes no sense to work without a send buffer. And
      // it's only a hint, which might be ignored by the implementation.
      // The idea is to send the response in pieces, to make sure that
      // the client reads everything and not just the first packet.
      // Calling flush() on the OutputStream isn't enough to achieve that.
      sock.setSendBufferSize(4);
    } catch (Exception ignore) {
      System.out.println(Catalog.NO_DISABLE_SEND_BUFFER_0.format());
      System.out.println(ignore);
    }

    if (printConnectionInfo)
     {
       StringBuilder sb = new StringBuilder(120);
       sb.append(handlerName)
         .append(": ")
         .append(Catalog.RECEIVE_FROM_1.format(sock.getRemoteSocketAddress()));
       System.out.println(sb);
     }

    // the following calls close the socket on error, so let exceptions pass
    ByteBuffer request  = readRequest(sock);
    ByteBuffer response = handleRequest(sock, request);
    sendResponse(sock, response);

    // single thread + blocking IO means no keep-alive
    sock.close();

  }
/**
   * Accepts the next connection, reads a request and serves it.
   * Repeatedly called by {@link #run}.
   * Blocks until there is a connection or a problem.
   *
   * @throws Exception        in case of a problem
   */
Accepts the next connection, reads a request and serves it.
Repeatedly called by  #run.
Blocks until there is a connection or a problem.

@throws Exception        in case of a problem
Accepts the next connection reads a request and serves it . Repeatedly called by #run . Blocks until there is a connection or a problem . @throws Exception in case of a problem
protected void acceptAndServeRequest()
    throws Exception
  {
    Socket sock = srvSocket.accept();
    try {
      sock.setSendBufferSize(4);
    } catch (Exception ignore) {
      System.out.println(Catalog.NO_DISABLE_SEND_BUFFER_0.format());
      System.out.println(ignore);
    }
    if (printConnectionInfo)
     {
       StringBuilder sb = new StringBuilder(120);
       sb.append(handlerName)
         .append(": ")
         .append(Catalog.RECEIVE_FROM_1.format(sock.getRemoteSocketAddress()));
       System.out.println(sb);
     }
    ByteBuffer request  = readRequest(sock);
    ByteBuffer response = handleRequest(sock, request);
    sendResponse(sock, response);
    sock.close();
  }
protected void acceptAndServeRequest ( ) throws Exception { Socket sock = srvSocket . accept ( ) ; try { sock . setSendBufferSize ( 4 ) ; } catch ( Exception ignore ) { System . out . println ( Catalog . NO_DISABLE_SEND_BUFFER_0 . format ( ) ) ; System . out . println ( ignore ) ; } if ( printConnectionInfo ) { StringBuilder sb = new StringBuilder ( 120 ) ; sb . append ( handlerName ) . append ( ": " ) . append ( Catalog . RECEIVE_FROM_1 . format ( sock . getRemoteSocketAddress ( ) ) ) ; System . out . println ( sb ) ; } ByteBuffer request = readRequest ( sock ) ; ByteBuffer response = handleRequest ( sock , request ) ; sendResponse ( sock , response ) ; sock . close ( ) ; }
Accepts the next connection, reads a request and serves it.
Accepts the next connection reads a request and serves it .
// Of course it makes no sense to work without a send buffer. And // it's only a hint, which might be ignored by the implementation. // The idea is to send the response in pieces, to make sure that // the client reads everything and not just the first packet. // Calling flush() on the OutputStream isn't enough to achieve that. // the following calls close the socket on error, so let exceptions pass // single thread + blocking IO means no keep-alive