using System; using System.Net; namespace Microsoft.Xna.Framework.Net { /// /// Defines the contract for a network transport layer, providing methods for sending and receiving data. /// public interface INetworkTransport : IDisposable { /// /// Receives data from the network in a blocking manner. /// /// A tuple containing the received data and the sender's endpoint. (byte[] data, IPEndPoint sender) Receive(); /// /// Receives data from the network asynchronously. /// /// A task that represents the asynchronous operation. The result contains the received data and the sender's endpoint. Task<(byte[] data, IPEndPoint sender)> ReceiveAsync(); /// /// Sends data to the specified endpoint in a blocking manner. /// /// The data to send. /// The endpoint to send the data to. void Send(byte[] data, IPEndPoint endpoint); /// /// Sends data to the specified endpoint asynchronously. /// /// The data to send. /// The endpoint to send the data to. /// A task that represents the asynchronous operation. Task SendAsync(byte[] data, IPEndPoint endpoint); /// /// Binds the transport to a local endpoint for receiving data. /// void Bind(); /// /// Indicates whether the transport is currently bound to a local endpoint. /// bool IsBound { get; } } }