UdpPacket

System.Net.Sockets

Class UdpPacket

Represents a UDP packet for sending and receiving data.

Namespace: System.Net.Sockets

Assembly: System.Net.Sockets.dll

Remarks

The UdpPacket class provides a structured way to work with UDP packets. It encapsulates the data buffer, remote endpoint, and other relevant information for UDP communication. This class is typically used in conjunction with classes like UdpClient or lower-level socket APIs.

It's important to note that while this class represents a packet, the actual underlying network stack manages the details of UDP datagrams, including segmentation, reassembly, and error checking (though UDP itself is unreliable).

Constructor

  • UdpPacket(byte[] data, EndPoint remoteEndPoint) [Show Details]

    Initializes a new instance of the UdpPacket class with the specified data and remote endpoint.

    data
    A byte array containing the data of the UDP packet.
    remoteEndPoint
    The endpoint of the remote host to which the packet is destined.
    public UdpPacket(byte[] data, EndPoint remoteEndPoint) { // Implementation details }
  • UdpPacket(byte[] buffer, int offset, int size, EndPoint remoteEndPoint) [Show Details]

    Initializes a new instance of the UdpPacket class with data from a specified portion of a byte array and the remote endpoint.

    buffer
    A byte array containing the data for the UDP packet.
    offset
    The starting position within the buffer.
    size
    The number of bytes in the packet data.
    remoteEndPoint
    The endpoint of the remote host.
    public UdpPacket(byte[] buffer, int offset, int size, EndPoint remoteEndPoint) { // Implementation details }

Properties

  • Data (byte[]) [Show Details]

    Gets the byte array containing the data of the UDP packet.

    public byte[] Data { get; }
  • RemoteEndPoint (EndPoint) [Show Details]

    Gets the endpoint of the remote host that sent or will receive the UDP packet.

    public EndPoint RemoteEndPoint { get; }
  • Size (int) [Show Details]

    Gets the size of the UDP packet data in bytes.

    public int Size { get; }