Class UdpReceiver
A basic UDP socket manager. The RTP channel may need both an RTP and Control socket. This class encapsulates
the common logic for UDP socket management.
Inheritance
System.Object
UdpReceiver
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: SIPSorcery.dll
Syntax
Constructors
|
Improve this Doc
View Source
UdpReceiver(Socket, Int32)
Declaration
public UdpReceiver(Socket socket, int mtu = 3000)
Parameters
Type |
Name |
Description |
System.Net.Sockets.Socket |
socket |
|
System.Int32 |
mtu |
|
Fields
|
Improve this Doc
View Source
logger
Declaration
protected static ILogger logger
Field Value
Type |
Description |
Microsoft.Extensions.Logging.ILogger |
|
|
Improve this Doc
View Source
m_addressFamily
Declaration
protected AddressFamily m_addressFamily
Field Value
Type |
Description |
System.Net.Sockets.AddressFamily |
|
|
Improve this Doc
View Source
m_isClosed
Declaration
protected bool m_isClosed
Field Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
m_isRunningReceive
Declaration
protected bool m_isRunningReceive
Field Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
m_localEndPoint
Declaration
protected IPEndPoint m_localEndPoint
Field Value
Type |
Description |
System.Net.IPEndPoint |
|
|
Improve this Doc
View Source
m_recvBuffer
Declaration
protected byte[] m_recvBuffer
Field Value
Type |
Description |
System.Byte[] |
|
|
Improve this Doc
View Source
m_socket
Declaration
protected readonly Socket m_socket
Field Value
Type |
Description |
System.Net.Sockets.Socket |
|
|
Improve this Doc
View Source
RECEIVE_BUFFER_SIZE
MTU is 1452 bytes so this should be heaps [AC 03 Nov 2024: turns out it's not when considering UDP fragmentation can
result in a max UDP payload of 65535 - 8 (header) = 65527 bytes].
An issue was reported with a real World WeBRTC implementation producing UDP packet sizes of 2144 byes #1045. Consequently
updated from 2048 to 3000.
Declaration
protected const int RECEIVE_BUFFER_SIZE = 3000
Field Value
Type |
Description |
System.Int32 |
|
Properties
|
Improve this Doc
View Source
IsClosed
Declaration
public virtual bool IsClosed { get; protected set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsRunningReceive
Declaration
public virtual bool IsRunningReceive { get; protected set; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
|
Improve this Doc
View Source
BeginReceiveFrom()
Starts the receive. This method returns immediately. An event will be fired in the corresponding "End" event to
return any data received.
Declaration
public virtual void BeginReceiveFrom()
|
Improve this Doc
View Source
CallOnPacketReceivedCallback(Int32, IPEndPoint, Byte[])
Declaration
protected virtual void CallOnPacketReceivedCallback(int localPort, IPEndPoint remoteEndPoint, byte[] packet)
Parameters
Type |
Name |
Description |
System.Int32 |
localPort |
|
System.Net.IPEndPoint |
remoteEndPoint |
|
System.Byte[] |
packet |
|
|
Improve this Doc
View Source
Close(String)
Closes the socket and stops any new receives from being initiated.
Declaration
public virtual void Close(string reason)
Parameters
Type |
Name |
Description |
System.String |
reason |
|
|
Improve this Doc
View Source
EndReceiveFrom(IAsyncResult)
Handler for end of the begin receive call.
Declaration
protected virtual void EndReceiveFrom(IAsyncResult ar)
Parameters
Type |
Name |
Description |
System.IAsyncResult |
ar |
Contains the results of the receive.
|
Events
|
Improve this Doc
View Source
OnClosed
Fires when there is an error attempting to receive on the UDP socket.
Declaration
public event Action<string> OnClosed
Event Type
Type |
Description |
System.Action<System.String> |
|
|
Improve this Doc
View Source
OnPacketReceived
Fires when a new packet has been received on the UDP socket.
Declaration
public event PacketReceivedDelegate OnPacketReceived
Event Type
Extension Methods