|
ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
|
Implements a TCP client for connecting to a server, sending, and receiving data. Provides both synchronous and asynchronous operations. More...
Public Member Functions | |
| TcpClient (string address, int port, TcpClientOptions options) | |
| Initializes a new instance of the TcpClient class. | |
| INetworkStatistics | GetNetworkStatistics () |
| Gets the network statistics associated with the client. | |
| virtual bool | Connect () |
| Connects the client to the server synchronously. | |
| virtual bool | Disconnect () |
| Disconnects the client from the server synchronously. | |
| virtual bool | Reconnect () |
| Reconnects the client to the server by first disconnecting and then reconnecting. | |
| virtual bool | ConnectAsync () |
| Connects the client to the server asynchronously. | |
| virtual bool | DisconnectAsync () |
| Disconnects the client from the server asynchronously. | |
| virtual bool | ReconnectAsync () |
| Reconnects the client to the server asynchronously by first disconnecting and then reconnecting. | |
| virtual int | Send (byte[] buffer) |
| Sends data to the server synchronously. | |
| virtual int | Send (byte[] buffer, int position, int length) |
| Sends data to the server synchronously starting from a specific position in the buffer. | |
| virtual bool | SendAsync (byte[] buffer) |
| Sends data to the server asynchronously. | |
| virtual bool | SendAsync (byte[] buffer, int position, int length) |
| Sends data to the server asynchronously starting from a specific position in the buffer. | |
| void | Dispose () |
| Disposes the TCP client, releasing all resources. | |
Public Member Functions inherited from XmobiTea.ProtonNetClient.IClient | |
Protected Member Functions | |
| virtual void | OnConnecting () |
| Called when the client is in the process of connecting. Can be overridden in derived classes to handle the event. | |
| virtual void | OnConnected () |
| Called when the client has successfully connected to the server. Can be overridden in derived classes to handle the event. | |
| virtual void | OnDisconnecting () |
| Called when the client is in the process of disconnecting. Can be overridden in derived classes to handle the event. | |
| virtual void | OnDisconnected () |
| Called when the client has successfully disconnected from the server. Can be overridden in derived classes to handle the event. | |
| virtual void | OnReceived (byte[] buffer, int position, int length) |
| Called when data is received from the server. Can be overridden in derived classes to handle the event. | |
| virtual void | OnSent (int sent, int pending) |
| Called when data is successfully sent to the server. Can be overridden in derived classes to handle the event. | |
| virtual void | OnEmpty () |
| Called when the send buffer is empty. Can be overridden in derived classes to handle the event. | |
| virtual void | OnError (SocketError error) |
| Called when an error occurs during socket operations. Can be overridden in derived classes to handle the event. | |
| virtual void | Dispose (bool disposingManagedResources) |
| Disposes the TCP client, releasing managed resources if specified. | |
Properties | |
| string | Id [get] |
| Gets the unique identifier for this TCP client instance. | |
| string | Address [get] |
| Gets the server address to which the client is connected. | |
| int | Port [get] |
| Gets the port number on the server to which the client is connected. | |
| EndPoint | EndPoint [get] |
| Gets the endpoint representing the server's address and port. | |
| Socket | Socket [get] |
| Gets the underlying socket used for the connection. | |
| TcpClientOptions | Options [get] |
| Gets the options used to configure the TCP client. | |
| bool | IsConnecting [get] |
| Gets a value indicating whether the client is currently connecting. | |
| bool | IsConnected [get] |
| Gets a value indicating whether the client is connected to the server. | |
| bool | IsDisposed [get] |
| Gets a value indicating whether the client has been disposed. | |
| bool | IsSocketDisposed [get] |
| Gets a value indicating whether the socket has been disposed. | |
Implements a TCP client for connecting to a server, sending, and receiving data. Provides both synchronous and asynchronous operations.
| XmobiTea.ProtonNetClient.TcpClient.TcpClient | ( | string | address, |
| int | port, | ||
| TcpClientOptions | options ) |
Initializes a new instance of the TcpClient class.
| address | The server address to connect to. |
| port | The port number on the server. |
| options | TCP client options for configuring the connection. |
|
virtual |
Connects the client to the server synchronously.
Implements XmobiTea.ProtonNetClient.IClient.
Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketTcpClient, XmobiTea.ProtonNet.Client.Socket.Clients.SocketWsClient, and XmobiTea.ProtonNetClient.WsClient.
|
virtual |
Connects the client to the server asynchronously.
Implements XmobiTea.ProtonNetClient.IClient.
Reimplemented in XmobiTea.ProtonNetClient.WsClient.
|
virtual |
Disconnects the client from the server synchronously.
Implements XmobiTea.ProtonNetClient.IClient.
Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketTcpClient, and XmobiTea.ProtonNet.Client.Socket.Clients.SocketWsClient.
|
virtual |
Disconnects the client from the server asynchronously.
Implements XmobiTea.ProtonNetClient.IClient.
|
protectedvirtual |
Disposes the TCP client, releasing managed resources if specified.
| disposingManagedResources | True to release managed resources; otherwise, false. |
| INetworkStatistics XmobiTea.ProtonNetClient.TcpClient.GetNetworkStatistics | ( | ) |
Gets the network statistics associated with the client.
Implements XmobiTea.ProtonNetClient.IClient.
|
protectedvirtual |
Called when the client has successfully connected to the server. Can be overridden in derived classes to handle the event.
Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketTcpClient, and XmobiTea.ProtonNetClient.WsClient.
|
protectedvirtual |
Called when the client has successfully disconnected from the server. Can be overridden in derived classes to handle the event.
Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketTcpClient, XmobiTea.ProtonNet.Client.Socket.Clients.SocketWsClient, XmobiTea.ProtonNetClient.HttpClient, and XmobiTea.ProtonNetClient.WsClient.
|
protectedvirtual |
Called when the client is in the process of disconnecting. Can be overridden in derived classes to handle the event.
Reimplemented in XmobiTea.ProtonNetClient.WsClient.
|
protectedvirtual |
Called when an error occurs during socket operations. Can be overridden in derived classes to handle the event.
| error | The socket error that occurred. |
|
protectedvirtual |
Called when data is received from the server. Can be overridden in derived classes to handle the event.
| buffer | The buffer containing the received data. |
| position | The starting position in the buffer. |
| length | The length of the received data. |
Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketTcpClient, XmobiTea.ProtonNetClient.HttpClient, and XmobiTea.ProtonNetClient.WsClient.
|
protectedvirtual |
Called when data is successfully sent to the server. Can be overridden in derived classes to handle the event.
| sent | The number of bytes sent. |
| pending | The number of bytes pending in the send buffer. |
|
virtual |
Reconnects the client to the server by first disconnecting and then reconnecting.
Implements XmobiTea.ProtonNetClient.IClient.
Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketTcpClient, and XmobiTea.ProtonNet.Client.Socket.Clients.SocketWsClient.
|
virtual |
Reconnects the client to the server asynchronously by first disconnecting and then reconnecting.
Implements XmobiTea.ProtonNetClient.IClient.
|
virtual |
Sends data to the server synchronously.
| buffer | The data to send. |
Implements XmobiTea.ProtonNetClient.IClient.
Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketWsClient.
|
virtual |
Sends data to the server synchronously starting from a specific position in the buffer.
| buffer | The data to send. |
| position | The starting position in the buffer. |
| length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IClient.
|
virtual |
Sends data to the server asynchronously.
| buffer | The data to send. |
Implements XmobiTea.ProtonNetClient.IClient.
Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketWsClient.
|
virtual |
Sends data to the server asynchronously starting from a specific position in the buffer.
| buffer | The data to send. |
| position | The starting position in the buffer. |
| length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IClient.