Condividi tramite


DatagramSocket.TrafficClass Property

Definition

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

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

if the socket is closed or the option is invalid.

if the socket is closed or the option could not be set.

Remarks

Property getter documentation:

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

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 DatagramSocket.

Added in 1.4.

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

Property setter documentation:

Sets traffic class or type-of-service octet in the IP datagram header for datagrams sent from this DatagramSocket. 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.

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.DatagramSocket.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