nl:: Inet:: UDPEndPoint
#include <src/inet/UDPEndPoint.h>
此类的对象表示 UDP 传输端点。
摘要
在系统进行相应配置时,Nest Inet 层封装了与 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 消息。
|
公共函数
Bind
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.
具体说明 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||||||
返回值 |
|