Sdílet prostřednictvím


Socket.TrafficClass Property

Definition

Gets traffic class or type-of-service in the IP header for packets sent from this Socket -or- Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket.

public virtual int TrafficClass { [Android.Runtime.Register("getTrafficClass", "()I", "GetGetTrafficClassHandler")] get; [Android.Runtime.Register("setTrafficClass", "(I)V", "GetSetTrafficClass_IHandler")] set; }
[<get: Android.Runtime.Register("getTrafficClass", "()I", "GetGetTrafficClassHandler")>]
[<set: Android.Runtime.Register("setTrafficClass", "(I)V", "GetSetTrafficClass_IHandler")>]
member this.TrafficClass : int with get, set

Property Value

the traffic class or type-of-service already set

Attributes

Exceptions

Remarks

Property getter documentation:

Gets traffic class or type-of-service in the IP header for packets sent from this Socket

As the underlying network implementation may ignore the traffic class or type-of-service set using #setTrafficClass(int) this method may return a different value than was previously set using the #setTrafficClass(int) method on this Socket.

Added in 1.4.

Java documentation for java.net.Socket.getTrafficClass().

Property setter documentation:

Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket. As the underlying network implementation may ignore this value applications should consider it a hint.

The tc <B>must</B> be in the range 0 <= tc <= 255 or an IllegalArgumentException will be thrown.

Notes:

For Internet Protocol v4 the value consists of an integer, the least significant 8 bits of which represent the value of the TOS octet in IP packets sent by the socket. RFC 1349 defines the TOS values as follows:

<UL> <LI>IPTOS_LOWCOST (0x02)</LI> <LI>IPTOS_RELIABILITY (0x04)</LI> <LI>IPTOS_THROUGHPUT (0x08)</LI> <LI>IPTOS_LOWDELAY (0x10)</LI> </UL> The last low order bit is always ignored as this corresponds to the MBZ (must be zero) bit.

Setting bits in the precedence field may result in a SocketException indicating that the operation is not permitted.

As RFC 1122 section 4.2.4.2 indicates, a compliant TCP implementation should, but is not required to, let application change the TOS field during the lifetime of a connection. So whether the type-of-service field can be changed after the TCP connection has been established depends on the implementation in the underlying platform. Applications should not assume that they can change the TOS field after the connection.

For Internet Protocol v6 tc is the value that would be placed into the sin6_flowinfo field of the IP header.

Added in 1.4.

Java documentation for java.net.Socket.setTrafficClass(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also