DatagramPacket Constructors

Definition

Overloads

DatagramPacket(Byte[], Int32)

Constructs a DatagramPacket for receiving packets of length length.

DatagramPacket(Byte[], Int32, SocketAddress)

Constructs a datagram packet for sending packets of length length to the specified port number on the specified host.

DatagramPacket(Byte[], Int32, Int32)

Constructs a DatagramPacket for receiving packets of length length, specifying an offset into the buffer.

DatagramPacket(Byte[], Int32, InetAddress, Int32)

Constructs a datagram packet for sending packets of length length to the specified port number on the specified host.

DatagramPacket(Byte[], Int32, Int32, SocketAddress)

Constructs a datagram packet for sending packets of length length with offset ioffsetto the specified port number on the specified host.

DatagramPacket(Byte[], Int32, Int32, InetAddress, Int32)

Constructs a datagram packet for sending packets of length length with offset ioffsetto the specified port number on the specified host.

DatagramPacket(Byte[], Int32)

Constructs a DatagramPacket for receiving packets of length length.

[Android.Runtime.Register(".ctor", "([BI)V", "")]
public DatagramPacket (byte[]? buf, int length);
[<Android.Runtime.Register(".ctor", "([BI)V", "")>]
new Java.Net.DatagramPacket : byte[] * int -> Java.Net.DatagramPacket

Parameters

buf
Byte[]

buffer for holding the incoming datagram.

length
Int32

the number of bytes to read.

Attributes

Remarks

Constructs a DatagramPacket for receiving packets of length length.

The length argument must be less than or equal to buf.length.

Java documentation for java.net.DatagramPacket.DatagramPacket(byte[], 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

DatagramPacket(Byte[], Int32, SocketAddress)

Constructs a datagram packet for sending packets of length length to the specified port number on the specified host.

[Android.Runtime.Register(".ctor", "([BILjava/net/SocketAddress;)V", "")]
public DatagramPacket (byte[]? buf, int length, Java.Net.SocketAddress? address);
[<Android.Runtime.Register(".ctor", "([BILjava/net/SocketAddress;)V", "")>]
new Java.Net.DatagramPacket : byte[] * int * Java.Net.SocketAddress -> Java.Net.DatagramPacket

Parameters

buf
Byte[]

the packet data.

length
Int32

the packet length.

address
SocketAddress

the destination address.

Attributes

Exceptions

if an error in the underlying protocol occurs.

Remarks

Constructs a datagram packet for sending packets of length length to the specified port number on the specified host. The length argument must be less than or equal to buf.length.

Added in 1.4.

Java documentation for java.net.DatagramPacket.DatagramPacket(byte[], int, java.net.SocketAddress).

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

DatagramPacket(Byte[], Int32, Int32)

Constructs a DatagramPacket for receiving packets of length length, specifying an offset into the buffer.

[Android.Runtime.Register(".ctor", "([BII)V", "")]
public DatagramPacket (byte[]? buf, int offset, int length);
[<Android.Runtime.Register(".ctor", "([BII)V", "")>]
new Java.Net.DatagramPacket : byte[] * int * int -> Java.Net.DatagramPacket

Parameters

buf
Byte[]

buffer for holding the incoming datagram.

offset
Int32

the offset for the buffer

length
Int32

the number of bytes to read.

Attributes

Remarks

Constructs a DatagramPacket for receiving packets of length length, specifying an offset into the buffer.

The length argument must be less than or equal to buf.length.

Added in 1.2.

Java documentation for java.net.DatagramPacket.DatagramPacket(byte[], int, 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

DatagramPacket(Byte[], Int32, InetAddress, Int32)

Constructs a datagram packet for sending packets of length length to the specified port number on the specified host.

[Android.Runtime.Register(".ctor", "([BILjava/net/InetAddress;I)V", "")]
public DatagramPacket (byte[]? buf, int length, Java.Net.InetAddress? address, int port);
[<Android.Runtime.Register(".ctor", "([BILjava/net/InetAddress;I)V", "")>]
new Java.Net.DatagramPacket : byte[] * int * Java.Net.InetAddress * int -> Java.Net.DatagramPacket

Parameters

buf
Byte[]

the packet data.

length
Int32

the packet length.

address
InetAddress

the destination address.

port
Int32

the destination port number.

Attributes

Remarks

Constructs a datagram packet for sending packets of length length to the specified port number on the specified host. The length argument must be less than or equal to buf.length.

<em>Android note</em>: Up to and including API 25 this method declared that a SocketException can be thrown, although the exception is never thrown. Code compiled against a newer SDK does not need to catch the exception and will be binary compatible with older versions of Android.

Java documentation for java.net.DatagramPacket.DatagramPacket(byte[], int, java.net.InetAddress, 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

DatagramPacket(Byte[], Int32, Int32, SocketAddress)

Constructs a datagram packet for sending packets of length length with offset ioffsetto the specified port number on the specified host.

[Android.Runtime.Register(".ctor", "([BIILjava/net/SocketAddress;)V", "")]
public DatagramPacket (byte[]? buf, int offset, int length, Java.Net.SocketAddress? address);
[<Android.Runtime.Register(".ctor", "([BIILjava/net/SocketAddress;)V", "")>]
new Java.Net.DatagramPacket : byte[] * int * int * Java.Net.SocketAddress -> Java.Net.DatagramPacket

Parameters

buf
Byte[]

the packet data.

offset
Int32

the packet data offset.

length
Int32

the packet data length.

address
SocketAddress

the destination socket address.

Attributes

Exceptions

if an error in the underlying protocol occurs.

Remarks

Constructs a datagram packet for sending packets of length length with offset ioffsetto the specified port number on the specified host. The length argument must be less than or equal to buf.length.

<em>Android note</em>: Up to and including API 25 this method declared that a SocketException can be thrown, although the exception is never thrown. Code compiled against a newer SDK does not need to catch the exception and will be binary compatible with older versions of Android.

Added in 1.4.

Java documentation for java.net.DatagramPacket.DatagramPacket(byte[], int, int, java.net.SocketAddress).

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

DatagramPacket(Byte[], Int32, Int32, InetAddress, Int32)

Constructs a datagram packet for sending packets of length length with offset ioffsetto the specified port number on the specified host.

[Android.Runtime.Register(".ctor", "([BIILjava/net/InetAddress;I)V", "")]
public DatagramPacket (byte[]? buf, int offset, int length, Java.Net.InetAddress? address, int port);
[<Android.Runtime.Register(".ctor", "([BIILjava/net/InetAddress;I)V", "")>]
new Java.Net.DatagramPacket : byte[] * int * int * Java.Net.InetAddress * int -> Java.Net.DatagramPacket

Parameters

buf
Byte[]

the packet data.

offset
Int32

the packet data offset.

length
Int32

the packet data length.

address
InetAddress

the destination address.

port
Int32

the destination port number.

Attributes

Remarks

Constructs a datagram packet for sending packets of length length with offset ioffsetto the specified port number on the specified host. The length argument must be less than or equal to buf.length.

Added in 1.2.

Java documentation for java.net.DatagramPacket.DatagramPacket(byte[], int, int, java.net.InetAddress, 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