nl:: Inet:: UDPEndPoint
#include <src/inet/UDPEndPoint.h>
這個類別的物件代表 UDP 傳輸端點。
摘要
Nest Inet Layer 會封裝與 UDP 傳輸端點互動的方法 (在 Linux 和 BSD 衍生系統上的 SOCK_DGRAM 通訊端) 或 LwIP UDP 通訊協定控制區塊 (因為系統會視情況進行設定)。
繼承
沿用來源: nl::Inet::IPEndPointBasis
公用函式 |
|
---|---|
Bind(IPAddressType addrType, IPAddress addr, uint16_t port, InterfaceId intfId)
|
將端點繫結至介面 IP 位址。
|
BindInterface(IPAddressType addrType, InterfaceId intf)
|
將端點繫結至網路介面。
|
Close(void)
|
void
關閉端點。
|
Free(void)
|
void
關閉端點並回收其記憶體。
|
GetBoundInterface(void)
|
InterfaceId
取得這個端點的繫結介面。
|
GetBoundPort(void)
|
uint16_t
|
Listen(void)
|
準備端點以接收 UDP 訊息。
|
SendMsg(const IPPacketInfo *pktInfo, Weave::System::PacketBuffer *msg, uint16_t sendFlags)
|
將 UDP 訊息傳送至指定的目的地。
|
SendTo(IPAddress addr, uint16_t port, Weave::System::PacketBuffer *msg, uint16_t sendFlags)
|
SendTo(addr, port, INET_NULL_INTERFACEID, msg, sendFlags) 的同義詞。 |
SendTo(IPAddress addr, uint16_t port, InterfaceId intfId, Weave::System::PacketBuffer *msg, uint16_t sendFlags)
|
將 UDP 訊息傳送至指定的目的地地址。
|
公用函式
繫結
INET_ERROR Bind( IPAddressType addrType, IPAddress addr, uint16_t port, InterfaceId intfId )
將端點繫結至介面 IP 位址。
將端點繫結至指定的網路介面 IP 位址。
詳細說明 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||||||
傳回值 |
|
在 LwIP 上,如果已經取得 LwIP 堆疊鎖定,就不得呼叫此方法。
BindInterface
INET_ERROR BindInterface( IPAddressType addrType, InterfaceId intf )
將端點繫結至網路介面。
將端點繫結至指定的網路介面 IP 位址。
詳細說明 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||
傳回值 |
|
在 LwIP 上,如果已經取得 LwIP 堆疊鎖定,就不得呼叫此方法。
關閉
void Close( void )
關閉端點。
如果設為 mState != kState_Closed
,則會關閉端點,並從符合通訊事件資格的端點組合中移除端點。
在 LwIP 系統中,如果已取得 LwIP 堆疊鎖定,就不能呼叫此方法。
免費
void Free( void )
關閉端點並回收其記憶體。
叫用 Close
方法,然後叫用 InetLayerBasis::Release
方法,將物件傳回其記憶體集區。
在 LwIP 系統中,如果已取得 LwIP 堆疊鎖定,就不能呼叫此方法。
GetBoundInterface
InterfaceId GetBoundInterface( void )
取得這個端點的繫結介面。
詳細說明 | |
---|---|
傳回 |
InterfaceId 繫結介面 ID。
|
GetBoundPort
uint16_t GetBoundPort( void )
聆聽
INET_ERROR Listen( void )
準備端點以接收 UDP 訊息。
如果 State
已經為 kState_Listening
,則不會執行任何作業,否則 mState
會設為 kState_Listening
,且根據平台的語意,將準備好接收 UDP 訊息。
詳細說明 | |||||
---|---|---|---|---|---|
傳回值 |
|
在 LwIP 上,如果已取得 LwIP 堆疊鎖定,就不得呼叫此方法
SendMsg
INET_ERROR SendMsg( const IPPacketInfo *pktInfo, Weave::System::PacketBuffer *msg, uint16_t sendFlags )
將 UDP 訊息傳送至指定的目的地。
Send the UDP message in \c msg to the destination address and port given in \c pktInfo. If \c pktInfo contains an interface id, the message will be sent over the specified interface. If \c pktInfo contains a source address, the given address will be used as the source of the UDP message. Where (sendFlags & kSendFlag_RetainBuffer) != 0, calls Weave::System::PacketBuffer::Free on behalf of the caller, otherwise this method deep-copies \c msg into a fresh object, and queues that for transmission, leaving the original \c msg available after return.
詳細說明 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||||
傳回值 |
|
SendTo
INET_ERROR SendTo( IPAddress addr, uint16_t port, Weave::System::PacketBuffer *msg, uint16_t sendFlags )
SendTo(addr, port, INET_NULL_INTERFACEID, msg, sendFlags)
的同義詞。
SendTo
INET_ERROR SendTo( IPAddress addr, uint16_t port, InterfaceId intfId, Weave::System::PacketBuffer *msg, uint16_t sendFlags )
將 UDP 訊息傳送至指定的目的地地址。
If possible, then this method sends the UDP message \c msg to the destination \c addr (with \c intfId used as the scope identifier for IPv6 link-local destinations) and \c port with the transmit option flags encoded in \c sendFlags. Where (sendFlags & kSendFlag_RetainBuffer) != 0, calls Weave::System::PacketBuffer::Free on behalf of the caller, otherwise this method deep-copies \c msg into a fresh object, and queues that for transmission, leaving the original \c msg available after return.
詳細說明 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||||
傳回值 |
|