Interface ISocket
Provides an interface simplifying the use of asynchronous communication using a socket.
public interface ISocket : IDisposable
- Inherited Members
Properties
Connected
Gets a value indicating whether the socket is connected.
bool Connected { get; }
Property Value
RemoteIPAddress
Gets the remote IP address of the socket connection.
string RemoteIPAddress { get; }
Property Value
Stream
Gets a stream for reading and writing data.
Stream Stream { get; }
Property Value
Methods
Accept()
Accepts a connection for the socket.
void Accept()
Authenticate(X509Certificate2)
Authenticates over the socket.
void Authenticate(X509Certificate2 certificate)
Parameters
certificate
X509Certificate2An X509Certificate2 that specifies authentication information.
Bind(EndPoint)
Binds the socket to a local end point.
void Bind(EndPoint localEndPoint)
Parameters
localEndPoint
EndPointThe local end point to which to bind the socket.
Close()
Closes the socket connection.
void Close()
Listen(int)
Starts listening to data received over the socket.
void Listen(int backlog)
Parameters
backlog
intThe number of pending connections to process.
Receive(byte[], int)
Receives data over the socket.
void Receive(byte[] buffer, int offset)
Parameters
buffer
byte[]The buffer into which the data will be read.
offset
intThe offset into the buffer at which the data will be read.
Send(byte[])
Sends data over the socket.
void Send(byte[] buffer)
Parameters
buffer
byte[]The data to be sent.
Events
AcceptError
Event raised when an error occurs accepting a connection.
event EventHandler<ErrorEventArgs> AcceptError
Event Type
Accepted
Event raised when a connection is accepted by the socket.
event EventHandler<AcceptEventArgs> Accepted
Event Type
AuthenticateError
Event raised when there is an error authenticating over the socket.
event EventHandler<ErrorEventArgs> AuthenticateError
Event Type
Authenticated
Event raised when authentication is completed over the socket.
event EventHandler Authenticated
Event Type
ReceiveError
Event raised when there is an error receiving data.
event EventHandler<ErrorEventArgs> ReceiveError
Event Type
Received
Event raised when data is received by the socket.
event EventHandler<ReceivedEventArgs> Received
Event Type
SendError
Event raised when there is an error sending data.
event EventHandler<ErrorEventArgs> SendError
Event Type
Sent
Event raised when data is sent through the socket.
event EventHandler Sent