Socket Socket Constructors

Definition

Overloads

Socket()

Creates a new unconnected socket.

Socket(Proxy) Socket(Proxy)

Creates a new unconnected socket using the given proxy type.

Socket(SocketImpl) Socket(SocketImpl)

Creates an unconnected socket with the given socket implementation.

Socket(InetAddress, Int32) Socket(InetAddress, Int32)

Creates a new streaming socket connected to the target host specified by the parameters dstAddress and dstPort.

Socket(IntPtr, JniHandleOwnership) Socket(IntPtr, JniHandleOwnership)

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

Socket(String, Int32) Socket(String, Int32)

Creates a new streaming socket connected to the target host specified by the parameters dstName and dstPort.

Socket(InetAddress, Int32, Boolean) Socket(InetAddress, Int32, Boolean)

Creates a new streaming or datagram socket connected to the target host specified by the parameters addr and port.

Socket(String, Int32, Boolean) Socket(String, Int32, Boolean)

Creates a new streaming or datagram socket connected to the target host specified by the parameters hostName and port.

Socket(InetAddress, Int32, InetAddress, Int32) Socket(InetAddress, Int32, InetAddress, Int32)

Creates a new streaming socket connected to the target host specified by the parameters dstAddress and dstPort.

Socket(String, Int32, InetAddress, Int32) Socket(String, Int32, InetAddress, Int32)

Creates a new streaming socket connected to the target host specified by the parameters dstName and dstPort.

Socket()

Creates a new unconnected socket.

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

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.

See also

Socket(Proxy) Socket(Proxy)

Creates a new unconnected socket using the given proxy type.

[Android.Runtime.Register(".ctor", "(Ljava/net/Proxy;)V", "")]
public Socket (Java.Net.Proxy proxy);
new Java.Net.Socket : Java.Net.Proxy -> Java.Net.Socket

Parameters

proxy
Proxy Proxy

Exceptions

if the argument proxy is null or of an invalid type.

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.

See also

Socket(SocketImpl) Socket(SocketImpl)

Creates an unconnected socket with the given socket implementation.

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

Parameters

Exceptions

if an error occurs while creating the socket.

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.

Socket(InetAddress, Int32) Socket(InetAddress, Int32)

Creates a new streaming socket connected to the target host specified by the parameters dstAddress and dstPort.

[Android.Runtime.Register(".ctor", "(Ljava/net/InetAddress;I)V", "")]
public Socket (Java.Net.InetAddress address, int port);
new Java.Net.Socket : Java.Net.InetAddress * int -> Java.Net.Socket

Parameters

port
Int32 Int32

Exceptions

if an error occurs while creating the socket.

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.

Socket(IntPtr, JniHandleOwnership) Socket(IntPtr, JniHandleOwnership)

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

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

Parameters

javaReference
IntPtr IntPtr

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

transfer
JniHandleOwnership 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.

Socket(String, Int32) Socket(String, Int32)

Creates a new streaming socket connected to the target host specified by the parameters dstName and dstPort.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;I)V", "")]
public Socket (string host, int port);
new Java.Net.Socket : string * int -> Java.Net.Socket

Parameters

host
String String
port
Int32 Int32

Exceptions

if the host name could not be resolved into an IP address.

if an error occurs while creating the socket.

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.

Socket(InetAddress, Int32, Boolean) Socket(InetAddress, Int32, Boolean)

Warning

This API is now obsolete.

Creates a new streaming or datagram socket connected to the target host specified by the parameters addr and port.

[Android.Runtime.Register(".ctor", "(Ljava/net/InetAddress;IZ)V", "")]
[System.Obsolete("deprecated")]
public Socket (Java.Net.InetAddress host, int port, bool stream);
new Java.Net.Socket : Java.Net.InetAddress * int * bool -> Java.Net.Socket

Parameters

port
Int32 Int32
stream
Boolean Boolean

Exceptions

if an error occurs while creating the socket.

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.

Socket(String, Int32, Boolean) Socket(String, Int32, Boolean)

Warning

This API is now obsolete.

Creates a new streaming or datagram socket connected to the target host specified by the parameters hostName and port.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;IZ)V", "")]
[System.Obsolete("deprecated")]
public Socket (string host, int port, bool stream);
new Java.Net.Socket : string * int * bool -> Java.Net.Socket

Parameters

host
String String
port
Int32 Int32
stream
Boolean Boolean

Exceptions

if the host name could not be resolved into an IP address.

if an error occurs while creating the socket.

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.

Socket(InetAddress, Int32, InetAddress, Int32) Socket(InetAddress, Int32, InetAddress, Int32)

Creates a new streaming socket connected to the target host specified by the parameters dstAddress and dstPort.

[Android.Runtime.Register(".ctor", "(Ljava/net/InetAddress;ILjava/net/InetAddress;I)V", "")]
public Socket (Java.Net.InetAddress address, int port, Java.Net.InetAddress localAddr, int localPort);
new Java.Net.Socket : Java.Net.InetAddress * int * Java.Net.InetAddress * int -> Java.Net.Socket

Parameters

port
Int32 Int32
localPort
Int32 Int32

Exceptions

if an error occurs while creating the socket.

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.

Socket(String, Int32, InetAddress, Int32) Socket(String, Int32, InetAddress, Int32)

Creates a new streaming socket connected to the target host specified by the parameters dstName and dstPort.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;ILjava/net/InetAddress;I)V", "")]
public Socket (string host, int port, Java.Net.InetAddress localAddr, int localPort);
new Java.Net.Socket : string * int * Java.Net.InetAddress * int -> Java.Net.Socket

Parameters

host
String String
port
Int32 Int32
localPort
Int32 Int32

Exceptions

if the host name could not be resolved into an IP address.

if an error occurs while creating the socket.

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