RealUdpSocket
Ecng.Net
Default implementation using real Socket.
Herda de: Disposable
Implementa: IUdpSocket, IDisposable
Construtores
RealUdpSocket
public RealUdpSocket()
realUdpSocket = RealUdpSocket()
Initializes a new instance for IPv4.
RealUdpSocket
public RealUdpSocket(AddressFamily addressFamily)
realUdpSocket = RealUdpSocket(addressFamily)
Initializes a new instance with specified address family.
- addressFamily
- The address family (IPv4 or IPv6).
Métodos
Bind
public void Bind(EndPoint localEP)
realUdpSocket.Bind(localEP)
Binds the socket to the specified endpoint.
- localEP
- The local endpoint.
DisposeManaged
protected override void DisposeManaged()
realUdpSocket.DisposeManaged()
Disposes the managed resources. Override this method to add custom clean up of managed resources.
JoinMulticast
public void JoinMulticast(MulticastSourceAddress address)
realUdpSocket.JoinMulticast(address)
Joins a multicast group.
- address
- The multicast source address.
LeaveMulticast
public void LeaveMulticast(MulticastSourceAddress address)
realUdpSocket.LeaveMulticast(address)
Leaves a multicast group.
- address
- The multicast source address.
LeaveMulticast
public void LeaveMulticast(IPAddress groupAddress)
realUdpSocket.LeaveMulticast(groupAddress)
Leaves a multicast group by IP address only.
- groupAddress
- The multicast group address.
ReceiveAsync
public ValueTask<int> ReceiveAsync(Memory<byte> buffer, SocketFlags socketFlags, CancellationToken cancellationToken)
result = realUdpSocket.ReceiveAsync(buffer, socketFlags, cancellationToken)
Receives data asynchronously.
- buffer
- The buffer to receive data into.
- socketFlags
- The socket flags.
- cancellationToken
- The cancellation token.
Retorna: The number of bytes received.
ReceiveFromAsync
public ValueTask<SocketReceiveFromResult> ReceiveFromAsync(Memory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEndPoint, CancellationToken cancellationToken)
result = realUdpSocket.ReceiveFromAsync(buffer, socketFlags, remoteEndPoint, cancellationToken)
Receives data asynchronously and returns the remote endpoint.
- buffer
- The buffer to receive data into.
- socketFlags
- The socket flags.
- remoteEndPoint
- The remote endpoint to receive from.
- cancellationToken
- The cancellation token.
Retorna: The result containing received bytes and remote endpoint.
SetSocketOption
public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, bool optionValue)
realUdpSocket.SetSocketOption(optionLevel, optionName, optionValue)
Sets a socket option.
- optionLevel
- The option level.
- optionName
- The option name.
- optionValue
- The option value.