Socket Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This class implements client sockets (also called just "sockets").
[Android.Runtime.Register("java/net/Socket", DoNotGenerateAcw=true)]
public class Socket : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ICloseable
[<Android.Runtime.Register("java/net/Socket", DoNotGenerateAcw=true)>]
type Socket = class
inherit Object
interface ICloseable
interface IJavaObject
interface IDisposable
interface IJavaPeerable
- Inheritance
- Derived
- Attributes
- Implements
Remarks
This class implements client sockets (also called just "sockets"). A socket is an endpoint for communication between two machines.
The actual work of the socket is performed by an instance of the SocketImpl
class. An application, by changing the socket factory that creates the socket implementation, can configure itself to create sockets appropriate to the local firewall.
Added in 1.0.
Java documentation for java.net.Socket
.
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.
Constructors
Socket() |
Creates an unconnected socket, with the system-default type of SocketImpl. |
Socket(InetAddress, Int32, Boolean) |
Obsolete.
Creates a socket and connects it to the specified port number at the specified IP address. |
Socket(InetAddress, Int32, InetAddress, Int32) |
Creates a socket and connects it to the specified remote address on the specified remote port. |
Socket(InetAddress, Int32) |
Creates a stream socket and connects it to the specified port number at the specified IP address. |
Socket(IntPtr, JniHandleOwnership) |
A constructor used when creating managed representations of JNI objects; called by the runtime. |
Socket(Proxy) |
Creates an unconnected socket, specifying the type of proxy, if any, that should be used regardless of any other settings. |
Socket(SocketImpl) |
Creates an unconnected Socket with a user-specified SocketImpl. |
Socket(String, Int32, Boolean) |
Obsolete.
Creates a stream socket and connects it to the specified port number on the named host. |
Socket(String, Int32, InetAddress, Int32) |
Creates a socket and connects it to the specified remote host on the specified remote port. |
Socket(String, Int32) |
Creates a stream socket and connects it to the specified port number on the named host. |
Properties
Channel |
Returns the unique |
Class |
Returns the runtime class of this |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
InetAddress |
Returns the address to which the socket is connected. |
InputStream |
Returns an input stream for this socket. |
IsBound |
Returns the binding state of the socket. |
IsClosed |
Returns the closed state of the socket. |
IsConnected |
Returns the connection state of the socket. |
IsInputShutdown |
Returns whether the read-half of the socket connection is closed. |
IsOutputShutdown |
Returns whether the write-half of the socket connection is closed. |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
KeepAlive |
Tests if |
LocalAddress |
Gets the local address to which the socket is bound. |
LocalPort |
Returns the local port number to which this socket is bound. |
LocalSocketAddress |
Returns the address of the endpoint this socket is bound to. |
OOBInline |
Tests if
|
OutputStream |
Returns an output stream for this socket. |
PeerReference | (Inherited from Object) |
Port |
Returns the remote port number to which this socket is connected. |
ReceiveBufferSize |
Gets the value of the |
RemoteSocketAddress |
Returns the address of the endpoint this socket is connected to, or
|
ReuseAddress |
Tests if |
SendBufferSize |
Get value of the |
SoLinger |
Returns setting for |
SoTimeout |
Returns setting for |
TcpNoDelay |
Tests if |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
TrafficClass |
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. |
Methods
Bind(SocketAddress) |
Binds the socket to a local address. |
Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
Close() |
Closes this socket. |
Connect(SocketAddress, Int32) |
Connects this socket to the server with a specified timeout value. |
Connect(SocketAddress) |
Connects this socket to the server. |
ConnectAsync(SocketAddress, Int32) | |
ConnectAsync(SocketAddress) | |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
GetOption(ISocketOption) |
Returns the value of a socket option. |
JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
SendUrgentData(Int32) |
Send one byte of urgent data on the socket. |
SendUrgentDataAsync(Int32) | |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
SetOption(ISocketOption, Object) |
Sets the value of a socket option. |
SetPerformancePreferences(Int32, Int32, Int32) |
Sets performance preferences for this socket. |
SetSocketImplFactory(ISocketImplFactory) |
Sets the client socket implementation factory for the application. |
SetSoLinger(Boolean, Int32) |
Enable/disable |
ShutdownInput() |
Places the input stream for this socket at "end of stream". |
ShutdownOutput() |
Disables the output stream for this socket. |
SupportedOptions() |
Returns a set of the socket options supported by this socket. |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnregisterFromRuntime() | (Inherited from Object) |
Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Explicit Interface Implementations
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |