ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
Loading...
Searching...
No Matches
XmobiTea.ProtonNetClient.UdpClient Class Reference

Implements a UDP client for sending and receiving data over a network. Provides both synchronous and asynchronous operations. More...

Inheritance diagram for XmobiTea.ProtonNetClient.UdpClient:
XmobiTea.ProtonNetClient.IUdpClient XmobiTea.ProtonNetClient.IClient XmobiTea.ProtonNet.Client.Socket.Clients.SocketUdpClient

Public Member Functions

 UdpClient (string address, int port, UdpClientOptions options)
 Initializes a new instance of the UdpClient 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 void JoinMulticastGroup (string address)
 Joins a multicast group by the specified address.
 
virtual void LeaveMulticastGroup (string address)
 Leaves a multicast group by the specified address.
 
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 int Send (EndPoint endPoint, byte[] buffer)
 Sends data to the specified endpoint synchronously.
 
virtual int Send (EndPoint endPoint, byte[] buffer, int position, int length)
 Sends data to the specified endpoint 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.
 
virtual bool SendAsync (EndPoint endPoint, byte[] buffer)
 Sends data to the specified endpoint asynchronously.
 
virtual bool SendAsync (EndPoint endPoint, byte[] buffer, int position, int length)
 Sends data to the specified endpoint asynchronously, starting from a specific position in the buffer.
 
void Dispose ()
 Disposes the UDP client, releasing all resources.
 
- Public Member Functions inherited from XmobiTea.ProtonNetClient.IUdpClient
- Public Member Functions inherited from XmobiTea.ProtonNetClient.IClient

Public Attributes

EndPoint EndPoint
 Gets or sets the endpoint representing the server's address and port.
 

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 OnJoinedMulticastGroup (string address)
 Called when the client successfully joins a multicast group. Can be overridden in derived classes to handle the event.
 
virtual void OnLeftMulticastGroup (string address)
 Called when the client successfully leaves a multicast group. Can be overridden in derived classes to handle the event.
 
virtual void OnReceived (EndPoint endPoint, 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 (EndPoint endPoint, int sent)
 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 UDP client, releasing managed resources if specified.
 

Properties

string Id [get]
 Gets the unique identifier for this UDP 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.
 
Socket Socket [get]
 Gets the underlying socket used for the connection.
 
UdpClientOptions Options [get]
 Gets the options used to configure the UDP 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 = true [get]
 Gets a value indicating whether the socket has been disposed.
 

Detailed Description

Implements a UDP client for sending and receiving data over a network. Provides both synchronous and asynchronous operations.

Constructor & Destructor Documentation

◆ UdpClient()

XmobiTea.ProtonNetClient.UdpClient.UdpClient ( string address,
int port,
UdpClientOptions options )

Initializes a new instance of the UdpClient class.

Parameters
addressThe server address to connect to.
portThe port number on the server.
optionsUDP client options for configuring the connection.

Member Function Documentation

◆ Connect()

virtual bool XmobiTea.ProtonNetClient.UdpClient.Connect ( )
virtual

Connects the client to the server synchronously.

Returns
True if the connection is successful; otherwise, false.

Implements XmobiTea.ProtonNetClient.IClient.

Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketUdpClient.

◆ ConnectAsync()

virtual bool XmobiTea.ProtonNetClient.UdpClient.ConnectAsync ( )
virtual

Connects the client to the server asynchronously.

Returns
True if the connection is successful; otherwise, false.

Implements XmobiTea.ProtonNetClient.IClient.

◆ Disconnect()

virtual bool XmobiTea.ProtonNetClient.UdpClient.Disconnect ( )
virtual

Disconnects the client from the server synchronously.

Returns
True if the disconnection is successful; otherwise, false.

Implements XmobiTea.ProtonNetClient.IClient.

Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketUdpClient.

◆ DisconnectAsync()

virtual bool XmobiTea.ProtonNetClient.UdpClient.DisconnectAsync ( )
virtual

Disconnects the client from the server asynchronously.

Returns
True if the disconnection is successful; otherwise, false.

Implements XmobiTea.ProtonNetClient.IClient.

◆ Dispose()

virtual void XmobiTea.ProtonNetClient.UdpClient.Dispose ( bool disposingManagedResources)
protectedvirtual

Disposes the UDP client, releasing managed resources if specified.

Parameters
disposingManagedResourcesTrue to release managed resources; otherwise, false.

◆ GetNetworkStatistics()

INetworkStatistics XmobiTea.ProtonNetClient.UdpClient.GetNetworkStatistics ( )

Gets the network statistics associated with the client.

Returns
An object implementing INetworkStatistics containing network statistics.

Implements XmobiTea.ProtonNetClient.IClient.

◆ JoinMulticastGroup()

virtual void XmobiTea.ProtonNetClient.UdpClient.JoinMulticastGroup ( string address)
virtual

Joins a multicast group by the specified address.

Parameters
addressThe address of the multicast group.

Implements XmobiTea.ProtonNetClient.IUdpClient.

◆ LeaveMulticastGroup()

virtual void XmobiTea.ProtonNetClient.UdpClient.LeaveMulticastGroup ( string address)
virtual

Leaves a multicast group by the specified address.

Parameters
addressThe address of the multicast group.

Implements XmobiTea.ProtonNetClient.IUdpClient.

◆ OnConnected()

virtual void XmobiTea.ProtonNetClient.UdpClient.OnConnected ( )
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.SocketUdpClient.

◆ OnDisconnected()

virtual void XmobiTea.ProtonNetClient.UdpClient.OnDisconnected ( )
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.SocketUdpClient.

◆ OnError()

virtual void XmobiTea.ProtonNetClient.UdpClient.OnError ( SocketError error)
protectedvirtual

Called when an error occurs during socket operations. Can be overridden in derived classes to handle the event.

Parameters
errorThe socket error that occurred.

◆ OnJoinedMulticastGroup()

virtual void XmobiTea.ProtonNetClient.UdpClient.OnJoinedMulticastGroup ( string address)
protectedvirtual

Called when the client successfully joins a multicast group. Can be overridden in derived classes to handle the event.

Parameters
addressThe address of the multicast group.

◆ OnLeftMulticastGroup()

virtual void XmobiTea.ProtonNetClient.UdpClient.OnLeftMulticastGroup ( string address)
protectedvirtual

Called when the client successfully leaves a multicast group. Can be overridden in derived classes to handle the event.

Parameters
addressThe address of the multicast group.

◆ OnReceived()

virtual void XmobiTea.ProtonNetClient.UdpClient.OnReceived ( EndPoint endPoint,
byte[] buffer,
int position,
int length )
protectedvirtual

Called when data is received from the server. Can be overridden in derived classes to handle the event.

Parameters
endPointThe endpoint from which the data is received.
bufferThe buffer containing the received data.
positionThe starting position in the buffer.
lengthThe length of the received data.

Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketUdpClient.

◆ OnSent()

virtual void XmobiTea.ProtonNetClient.UdpClient.OnSent ( EndPoint endPoint,
int sent )
protectedvirtual

Called when data is successfully sent to the server. Can be overridden in derived classes to handle the event.

Parameters
endPointThe endpoint to which the data was sent.
sentThe number of bytes sent.

◆ Reconnect()

virtual bool XmobiTea.ProtonNetClient.UdpClient.Reconnect ( )
virtual

Reconnects the client to the server by first disconnecting and then reconnecting.

Returns
True if the reconnection is successful; otherwise, false.

Implements XmobiTea.ProtonNetClient.IClient.

Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketUdpClient.

◆ ReconnectAsync()

virtual bool XmobiTea.ProtonNetClient.UdpClient.ReconnectAsync ( )
virtual

Reconnects the client to the server asynchronously by first disconnecting and then reconnecting.

Returns
True if the reconnection is successful; otherwise, false.

Implements XmobiTea.ProtonNetClient.IClient.

◆ Send() [1/4]

virtual int XmobiTea.ProtonNetClient.UdpClient.Send ( byte[] buffer)
virtual

Sends data to the server synchronously.

Parameters
bufferThe data to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetClient.IClient.

◆ Send() [2/4]

virtual int XmobiTea.ProtonNetClient.UdpClient.Send ( byte[] buffer,
int position,
int length )
virtual

Sends data to the server synchronously starting from a specific position in the buffer.

Parameters
bufferThe data to send.
positionThe starting position in the buffer.
lengthThe number of bytes to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetClient.IClient.

◆ Send() [3/4]

virtual int XmobiTea.ProtonNetClient.UdpClient.Send ( EndPoint endPoint,
byte[] buffer )
virtual

Sends data to the specified endpoint synchronously.

Parameters
endPointThe endpoint to which the data is sent.
bufferThe data to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetClient.IUdpClient.

◆ Send() [4/4]

virtual int XmobiTea.ProtonNetClient.UdpClient.Send ( EndPoint endPoint,
byte[] buffer,
int position,
int length )
virtual

Sends data to the specified endpoint synchronously, starting from a specific position in the buffer.

Parameters
endPointThe endpoint to which the data is sent.
bufferThe data to send.
positionThe starting position in the buffer.
lengthThe number of bytes to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetClient.IUdpClient.

◆ SendAsync() [1/4]

virtual bool XmobiTea.ProtonNetClient.UdpClient.SendAsync ( byte[] buffer)
virtual

Sends data to the server asynchronously.

Parameters
bufferThe data to send.
Returns
True if the data was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetClient.IClient.

◆ SendAsync() [2/4]

virtual bool XmobiTea.ProtonNetClient.UdpClient.SendAsync ( byte[] buffer,
int position,
int length )
virtual

Sends data to the server asynchronously starting from a specific position in the buffer.

Parameters
bufferThe data to send.
positionThe starting position in the buffer.
lengthThe number of bytes to send.
Returns
True if the data was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetClient.IClient.

◆ SendAsync() [3/4]

virtual bool XmobiTea.ProtonNetClient.UdpClient.SendAsync ( EndPoint endPoint,
byte[] buffer )
virtual

Sends data to the specified endpoint asynchronously.

Parameters
endPointThe endpoint to which the data is sent.
bufferThe data to send.
Returns
True if the data was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetClient.IUdpClient.

◆ SendAsync() [4/4]

virtual bool XmobiTea.ProtonNetClient.UdpClient.SendAsync ( EndPoint endPoint,
byte[] buffer,
int position,
int length )
virtual

Sends data to the specified endpoint asynchronously, starting from a specific position in the buffer.

Parameters
endPointThe endpoint to which the data is sent.
bufferThe data to send.
positionThe starting position in the buffer.
lengthThe number of bytes to send.
Returns
True if the data was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetClient.IUdpClient.


The documentation for this class was generated from the following file: