src/main/java/pityoulish/sockets/server/SimplisticSocketHandler.java
public ByteBuffer handleRequest(Socket sock, ByteBuffer request)
    throws Exception
  {
    try {
      // The client machine is (more or less) identified by the host address.
      // The port number there most likely changes for every request.
      InetAddress address = sock.getInetAddress();

      return reqHandler.handle(request, address);

    } catch (Exception x) {
      System.out.println(x.toString());
      sendErrorAndClose(x, sock);
      throw x;
    }

    // in case of success, the socket remains open

  }
/**
   * Handles a request that has been read from a socket.
   * Calls the {@link RequestHandler} and returns the response.
   *
   * @param sock        the socket from which the request was read
   * @param request     a byte buffer holding the request, backed by an array.
   *                    The request begins at the current position and
   *                    extends to the limit of the buffer.
   *
   * @return a byte buffer holding the response, backed by an array.
   *         The response begins at the current position and
   *         extends to the limit of the buffer.
   *         This value is a suitable parameter for {@link #sendResponse}.
   *
   * @throws Exception  in case of a problem
   */
Handles a request that has been read from a socket.
Calls the  RequestHandler and returns the response.

@param sock        the socket from which the request was read
@param request     a byte buffer holding the request, backed by an array.
The request begins at the current position and
extends to the limit of the buffer.

@return a byte buffer holding the response, backed by an array.
The response begins at the current position and
extends to the limit of the buffer.
This value is a suitable parameter for  #sendResponse.

@throws Exception  in case of a problem
Handles a request that has been read from a socket . Calls the RequestHandler and returns the response . @param sock the socket from which the request was read @param request a byte buffer holding the request backed by an array . The request begins at the current position and extends to the limit of the buffer . @return a byte buffer holding the response backed by an array . The response begins at the current position and extends to the limit of the buffer . This value is a suitable parameter for #sendResponse . @throws Exception in case of a problem
public ByteBuffer handleRequest(Socket sock, ByteBuffer request)
    throws Exception
  {
    try {
      InetAddress address = sock.getInetAddress();
      return reqHandler.handle(request, address);
    } catch (Exception x) {
      System.out.println(x.toString());
      sendErrorAndClose(x, sock);
      throw x;
    }
  }
public ByteBuffer handleRequest ( Socket sock , ByteBuffer request ) throws Exception { try { InetAddress address = sock . getInetAddress ( ) ; return reqHandler . handle ( request , address ) ; } catch ( Exception x ) { System . out . println ( x . toString ( ) ) ; sendErrorAndClose ( x , sock ) ; throw x ; } }
Handles a request that has been read from a socket.
Handles a request that has been read from a socket .
// The client machine is (more or less) identified by the host address. // The port number there most likely changes for every request. // in case of success, the socket remains open