@Override public String toString() { final StringBuilder msg = new StringBuilder(getClass().getSimpleName()).append("["); if (hasConnectTimeout()) { msg.append("connect timeout = ").append(getSoTimeout()).append(" ms "); } if (hasSoTimeout()) { msg.append("socket timeout = ").append(getSoTimeout()).append(" ms "); } if (hasSndBuffSize()) { msg.append("send buffer size = ").append(getSndBuffSize()).append(" "); } if (hasRcvBuffSize()) { msg.append("receive buffer size = ").append(getRcvBuffSize()).append(" "); } msg.append("keep alive = ").append(isKeepAlive()).append("]"); return msg.toString(); }
@Override public String toString() { final StringBuilder msg = new StringBuilder(getClass().getSimpleName()).append("["); if (hasConnectTimeout()) { msg.append("connect timeout = ").append(getSoTimeout()).append(" ms "); } if (hasSoTimeout()) { msg.append("socket timeout = ").append(getSoTimeout()).append(" ms "); } if (hasSndBuffSize()) { msg.append("send buffer size = ").append(getSndBuffSize()).append(" "); } if (hasRcvBuffSize()) { msg.append("receive buffer size = ").append(getRcvBuffSize()).append(" "); } msg.append("keep alive = ").append(isKeepAlive()).append("]"); return msg.toString(); }
/** * Configure the socket with the given socket options. This should be done before the socket is connected. * The connection timeout is not configurable - it must be used when connecting the socket. * * @param socket A not connected socket * @param options The socket options. If null, no socket options will be configured. */ public static void configureSocketOptions(Socket socket, SocketOptionsConfig options) throws SocketException { if (options != null) { if (options.isKeepAlive()) { socket.setKeepAlive(true); } if (options.hasSoTimeout()) { socket.setSoTimeout(options.getSoTimeout()); } if (options.hasSndBuffSize()) { socket.setSendBufferSize(options.getSndBuffSize()); } if (options.hasRcvBuffSize()) { socket.setReceiveBufferSize(options.getRcvBuffSize()); } } }
/** * Configure the socket with the given socket options. This should be done before the socket is connected. * The connection timeout is not configurable - it must be used when connecting the socket. * * @param socket A not connected socket * @param options The socket options. If null, no socket options will be configured. */ public static void configureSocketOptions(Socket socket, SocketOptionsConfig options) throws SocketException { if (options != null) { if (options.isKeepAlive()) { socket.setKeepAlive(true); } if (options.hasSoTimeout()) { socket.setSoTimeout(options.getSoTimeout()); } if (options.hasSndBuffSize()) { socket.setSendBufferSize(options.getSndBuffSize()); } if (options.hasRcvBuffSize()) { socket.setReceiveBufferSize(options.getRcvBuffSize()); } } }