IUdpSocket
Ecng.Net
Interface for UDP socket operations, enabling testing without real network.
Implementiert: IDisposable
Methoden
Bind
public void Bind(EndPoint localEP)
iUdpSocket.Bind(localEP)
Binds the socket to the specified endpoint.
- localEP
- The local endpoint.
JoinMulticast
public void JoinMulticast(MulticastSourceAddress address)
iUdpSocket.JoinMulticast(address)
Joins a multicast group.
- address
- The multicast source address.
LeaveMulticast
public void LeaveMulticast(MulticastSourceAddress address)
iUdpSocket.LeaveMulticast(address)
Leaves a multicast group.
- address
- The multicast source address.
LeaveMulticast
public void LeaveMulticast(IPAddress groupAddress)
iUdpSocket.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 = iUdpSocket.ReceiveAsync(buffer, socketFlags, cancellationToken)
Receives data asynchronously.
- buffer
- The buffer to receive data into.
- socketFlags
- The socket flags.
- cancellationToken
- The cancellation token.
Rückgabe: The number of bytes received.
ReceiveFromAsync
public ValueTask<SocketReceiveFromResult> ReceiveFromAsync(Memory<byte> buffer, SocketFlags socketFlags, EndPoint remoteEndPoint, CancellationToken cancellationToken)
result = iUdpSocket.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.
Rückgabe: The result containing received bytes and remote endpoint.
SetSocketOption
public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, bool optionValue)
iUdpSocket.SetSocketOption(optionLevel, optionName, optionValue)
Sets a socket option.
- optionLevel
- The option level.
- optionName
- The option name.
- optionValue
- The option value.