DatagramSocket Constructors

Definition

Overloads

DatagramSocket()

Constructs a datagram socket and binds it to any available port on the local host machine.

DatagramSocket(DatagramSocketImpl)

Creates an unbound datagram socket with the specified DatagramSocketImpl.

DatagramSocket(SocketAddress)

Creates a datagram socket, bound to the specified local socket address.

DatagramSocket(Int32)

Constructs a datagram socket and binds it to the specified port on the local host machine.

DatagramSocket(Int32, InetAddress)

Creates a datagram socket, bound to the specified local address.

DatagramSocket(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

DatagramSocket()

Constructs a datagram socket and binds it to any available port on the local host machine.

[Android.Runtime.Register(".ctor", "()V", "")]
public DatagramSocket ();
Attributes

Exceptions

if an error occurs while creating or binding the socket.

Remarks

Constructs a datagram socket and binds it to any available port on the local host machine. The socket will be bound to the InetAddress#isAnyLocalAddress wildcard address, an IP address chosen by the kernel.

If there is a security manager, its checkListen method is first called with 0 as its argument to ensure the operation is allowed. This could result in a SecurityException.

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

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

DatagramSocket(DatagramSocketImpl)

Creates an unbound datagram socket with the specified DatagramSocketImpl.

[Android.Runtime.Register(".ctor", "(Ljava/net/DatagramSocketImpl;)V", "")]
protected DatagramSocket (Java.Net.DatagramSocketImpl? impl);
[<Android.Runtime.Register(".ctor", "(Ljava/net/DatagramSocketImpl;)V", "")>]
new Java.Net.DatagramSocket : Java.Net.DatagramSocketImpl -> Java.Net.DatagramSocket

Parameters

impl
DatagramSocketImpl

an instance of a <B>DatagramSocketImpl</B> the subclass wishes to use on the DatagramSocket.

Attributes

Remarks

Creates an unbound datagram socket with the specified DatagramSocketImpl.

Added in 1.4.

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

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

DatagramSocket(SocketAddress)

Creates a datagram socket, bound to the specified local socket address.

[Android.Runtime.Register(".ctor", "(Ljava/net/SocketAddress;)V", "")]
public DatagramSocket (Java.Net.SocketAddress? bindaddr);
[<Android.Runtime.Register(".ctor", "(Ljava/net/SocketAddress;)V", "")>]
new Java.Net.DatagramSocket : Java.Net.SocketAddress -> Java.Net.DatagramSocket

Parameters

bindaddr
SocketAddress

local socket address to bind, or null for an unbound socket.

Attributes

Exceptions

if the SocketAddress is not supported

if a problem occurs creating or binding the socket.

Remarks

Creates a datagram socket, bound to the specified local socket address.

If, if the address is null, creates an unbound socket.

If there is a security manager, its checkListen method is first called with the port from the socket address as its argument to ensure the operation is allowed. This could result in a SecurityException.

Added in 1.4.

Java documentation for java.net.DatagramSocket.DatagramSocket(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

DatagramSocket(Int32)

Constructs a datagram socket and binds it to the specified port on the local host machine.

[Android.Runtime.Register(".ctor", "(I)V", "")]
public DatagramSocket (int port);
[<Android.Runtime.Register(".ctor", "(I)V", "")>]
new Java.Net.DatagramSocket : int -> Java.Net.DatagramSocket

Parameters

port
Int32

port to use.

Attributes

Exceptions

if an error occurs while creating or binding the socket.

Remarks

Constructs a datagram socket and binds it to the specified port on the local host machine. The socket will be bound to the InetAddress#isAnyLocalAddress wildcard address, an IP address chosen by the kernel.

If there is a security manager, its checkListen method is first called with the port argument as its argument to ensure the operation is allowed. This could result in a SecurityException.

Java documentation for java.net.DatagramSocket.DatagramSocket(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

DatagramSocket(Int32, InetAddress)

Creates a datagram socket, bound to the specified local address.

[Android.Runtime.Register(".ctor", "(ILjava/net/InetAddress;)V", "")]
public DatagramSocket (int port, Java.Net.InetAddress? laddr);
[<Android.Runtime.Register(".ctor", "(ILjava/net/InetAddress;)V", "")>]
new Java.Net.DatagramSocket : int * Java.Net.InetAddress -> Java.Net.DatagramSocket

Parameters

port
Int32

local port to use

laddr
InetAddress

local address to bind

Attributes

Exceptions

if an error occurs while creating or binding the socket.

Remarks

Creates a datagram socket, bound to the specified local address. The local port must be between 0 and 65535 inclusive. If the IP address is 0.0.0.0, the socket will be bound to the InetAddress#isAnyLocalAddress wildcard address, an IP address chosen by the kernel.

If there is a security manager, its checkListen method is first called with the port argument as its argument to ensure the operation is allowed. This could result in a SecurityException.

Added in 1.1.

Java documentation for java.net.DatagramSocket.DatagramSocket(int, java.net.InetAddress).

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

DatagramSocket(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

protected DatagramSocket (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Java.Net.DatagramSocket : nativeint * Android.Runtime.JniHandleOwnership -> Java.Net.DatagramSocket

Parameters

javaReference
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle javaReference

Remarks

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