Home | History | Annotate | Download | only in net
      1 /*******************************************************************************
      2  * Copyright 2011 See AUTHORS file.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *	 http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  ******************************************************************************/
     16 
     17 package com.badlogic.gdx.net;
     18 
     19 /** Options for {@link Socket} instances.
     20  *
     21  * @author mzechner
     22  * @author noblemaster */
     23 public class SocketHints {
     24 
     25 	/** The connection timeout in milliseconds. Not used for sockets created via server.accept(). */
     26 	public int connectTimeout = 5000;
     27 
     28 	/** Performance preferences are described by three integers whose values indicate the relative importance of short connection
     29 	 * time, low latency, and high bandwidth. The absolute values of the integers are irrelevant; in order to choose a protocol the
     30 	 * values are simply compared, with larger values indicating stronger preferences. Negative values represent a lower priority
     31 	 * than positive values. If the application prefers short connection time over both low latency and high bandwidth, for
     32 	 * example, then it could invoke this method with the values (1, 0, 0). If the application prefers high bandwidth above low
     33 	 * latency, and low latency above short connection time, then it could invoke this method with the values (0, 1, 2). */
     34 	public int performancePrefConnectionTime = 0;
     35 	public int performancePrefLatency = 1; // low latency
     36 	public int performancePrefBandwidth = 0;
     37 	/** The traffic class describes the type of connection that shall be established. The traffic class must be in the range 0 <=
     38 	 * trafficClass <= 255.
     39 	 * <p>
     40 	 * The traffic class is bitset created by bitwise-or'ing values such the following :
     41 	 * <ul>
     42 	 * <li>IPTOS_LOWCOST (0x02) - cheap!
     43 	 * <li>IPTOS_RELIABILITY (0x04) - reliable connection with little package loss.
     44 	 * <li>IPTOS_THROUGHPUT (0x08) - lots of data being sent.
     45 	 * <li>IPTOS_LOWDELAY (0x10) - low delay.
     46 	 * </ul> */
     47 	public int trafficClass = 0x14; // low delay + reliable
     48 	/** True to enable SO_KEEPALIVE. */
     49 	public boolean keepAlive = true;
     50 	/** True to enable TCP_NODELAY (disable/enable Nagle's algorithm). */
     51 	public boolean tcpNoDelay = true;
     52 	/** The SO_SNDBUF (send buffer) size in bytes. */
     53 	public int sendBufferSize = 4096;
     54 	/** The SO_RCVBUF (receive buffer) size in bytes. */
     55 	public int receiveBufferSize = 4096;
     56 	/** Enable/disable SO_LINGER with the specified linger time in seconds. Only affects socket close. */
     57 	public boolean linger = false;
     58 	/** The linger duration in seconds (NOT milliseconds!). Only used if linger is true! */
     59 	public int lingerDuration = 0;
     60 	/** Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. With this option set to a non-zero timeout, a read()
     61 	 * call on the InputStream associated with this Socket will block for only this amount of time */
     62 	public int socketTimeout = 0;
     63 }
     64