Partager via


ServerSocket Class

Definition

This class implements server sockets.

[Android.Runtime.Register("java/net/ServerSocket", DoNotGenerateAcw=true)]
public class ServerSocket : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ICloseable
[<Android.Runtime.Register("java/net/ServerSocket", DoNotGenerateAcw=true)>]
type ServerSocket = class
    inherit Object
    interface ICloseable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
ServerSocket
Derived
Attributes
Implements

Remarks

This class implements server sockets. A server socket waits for requests to come in over the network. It performs some operation based on that request, and then possibly returns a result to the requester.

The actual work of the server socket is performed by an instance of the SocketImpl class. An application can change the socket factory that creates the socket implementation to configure itself to create sockets appropriate to the local firewall.

Added in 1.0.

Java documentation for java.net.ServerSocket.

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

ServerSocket()

Creates an unbound server socket.

ServerSocket(Int32, Int32, InetAddress)

Create a server with the specified port, listen backlog, and local IP address to bind to.

ServerSocket(Int32, Int32)

Creates a server socket and binds it to the specified local port number, with the specified backlog.

ServerSocket(Int32)

Creates a server socket, bound to the specified port.

ServerSocket(IntPtr, JniHandleOwnership)

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

Properties

Channel

Returns the unique java.nio.channels.ServerSocketChannel object associated with this socket, if any.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
InetAddress

Returns the local address of this server socket.

IsBound

Returns the binding state of the ServerSocket.

IsClosed

Returns the closed state of the ServerSocket.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
LocalPort

Returns the port number on which this socket is listening.

LocalSocketAddress

Returns the address of the endpoint this socket is bound to.

PeerReference (Inherited from Object)
ReceiveBufferSize

Gets the value of the SocketOptions#SO_RCVBUF SO_RCVBUF option for this ServerSocket, that is the proposed buffer size that will be used for Sockets accepted from this ServerSocket. -or- Sets a default proposed value for the SocketOptions#SO_RCVBUF SO_RCVBUF option for sockets accepted from this ServerSocket.

ReuseAddress

Tests if SocketOptions#SO_REUSEADDR SO_REUSEADDR is enabled. -or- Enable/disable the SocketOptions#SO_REUSEADDR SO_REUSEADDR socket option.

SoTimeout

Retrieve setting for SocketOptions#SO_TIMEOUT SO_TIMEOUT. -or- Enable/disable SocketOptions#SO_TIMEOUT SO_TIMEOUT with the specified timeout, in milliseconds.

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.

Methods

Accept()

Listens for a connection to be made to this socket and accepts it.

AcceptAsync()
Bind(SocketAddress, Int32)

Binds the ServerSocket to a specific address (IP address and port number).

Bind(SocketAddress)

Binds the ServerSocket to a specific address (IP address and port number).

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Close()

Closes this socket.

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.

ImplAccept(Socket)

Subclasses of ServerSocket use this method to override accept() to return their own subclass of socket.

ImplAcceptAsync(Socket)
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)
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 ServerSocket.

SetSocketFactory(ISocketImplFactory)

Sets the server socket implementation factory for the application.

SupportedOptions()

Returns a set of the socket options supported by this server 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)

Applies to