src/main/java/pityoulish/sockets/client/MsgBoardClientHandlerImpl.java
public void sendRequest(Socket sock, ByteBuffer request)
    throws Exception
  {
    // To make it a bit harder for the server, don't send everything in a
    // single packet. At least, try to. The operating system might still
    // collect the pieces before sending them over the wire. Or they could
    // get glued together on the receiving side before the server process.

    int split = 4 + (int)(Math.random() * (double)(request.remaining()-3));
    if (beVerbose)
       System.out.println(Catalog.INFO_SPLITTING_AT_2.format
                          (split, request.remaining())      );

    OutputStream os = sock.getOutputStream();
    os.write(request.array(),
             request.position()+request.arrayOffset(),
             split);
    os.flush();
    if (split < request.remaining())
     {
       os.write(request.array(),
                request.position()+request.arrayOffset()+split,
                request.remaining()-split);
       os.flush();
     }
  }
/**
   * Sends a request over a socket.
   *
   * @param sock        the socket over which to send
   * @param request     the request to be sent
   *
   * @throws Exception  in case of a problem
   */
Sends a request over a socket.
@param sock        the socket over which to send
@param request     the request to be sent

@throws Exception  in case of a problem
Sends a request over a socket . @param sock the socket over which to send @param request the request to be sent @throws Exception in case of a problem
public void sendRequest(Socket sock, ByteBuffer request)
    throws Exception
  {
    int split = 4 + (int)(Math.random() * (double)(request.remaining()-3));
    if (beVerbose)
       System.out.println(Catalog.INFO_SPLITTING_AT_2.format
                          (split, request.remaining())      );
    OutputStream os = sock.getOutputStream();
    os.write(request.array(),
             request.position()+request.arrayOffset(),
             split);
    os.flush();
    if (split < request.remaining())
     {
       os.write(request.array(),
                request.position()+request.arrayOffset()+split,
                request.remaining()-split);
       os.flush();
     }
  }
public void sendRequest ( Socket sock , ByteBuffer request ) throws Exception { int split = 4 + ( int ) ( Math . random ( ) * ( double ) ( request . remaining ( ) - 3 ) ) ; if ( beVerbose ) System . out . println ( Catalog . INFO_SPLITTING_AT_2 . format ( split , request . remaining ( ) ) ) ; OutputStream os = sock . getOutputStream ( ) ; os . write ( request . array ( ) , request . position ( ) + request . arrayOffset ( ) , split ) ; os . flush ( ) ; if ( split < request . remaining ( ) ) { os . write ( request . array ( ) , request . position ( ) + request . arrayOffset ( ) + split , request . remaining ( ) - split ) ; os . flush ( ) ; } }
Sends a request over a socket.
Sends a request over a socket .
// To make it a bit harder for the server, don't send everything in a // single packet. At least, try to. The operating system might still // collect the pieces before sending them over the wire. Or they could // get glued together on the receiving side before the server process.