NL::内网:: UDP端点
#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 消息。 |
公共职能
绑定
INET_ERROR Bind( IPAddressType addrType, IPAddress addr, uint16_t port, InterfaceId intfId )
将端点绑定到接口 IP 地址。
将端点绑定到指定的网络接口 IP 地址。
细节 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
| ||||||||||||||
返回值 |
|
在 LwIP 上,不得在已获取 LwIP 堆栈锁的情况下调用此方法。
绑定接口
INET_ERROR BindInterface( IPAddressType addrType, InterfaceId intf )
将端点绑定到网络接口。
将端点绑定到指定的网络接口 IP 地址。
细节 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
| ||||||||||
返回值 |
|
在 LwIP 上,不得在已获取 LwIP 堆栈锁的情况下调用此方法。
关闭
void Close( void )
关闭端点。
如果mState != kState_Closed
,然后关闭端点,从端点集合资格通信事件的删除它。
在 LwIP 系统上,不得在已获取 LwIP 堆栈锁的情况下调用此方法。
自由
void Free( void )
获取绑定接口
InterfaceId GetBoundInterface( void )
获取此端点上的绑定接口。
细节 | |
---|---|
退货 | InterfaceId 绑定的接口 ID。 |
获取绑定端口
uint16_t GetBoundPort( void )
听
INET_ERROR Listen( void )
准备端点以接收 UDP 消息。
如果State
已经kState_Listening
,然后不进行任何操作,否则mState
设置为kState_Listening
和端点准备接收UDP消息,根据平台的语义。
细节 | |||||
---|---|---|---|---|---|
返回值 |
|
在 LwIP 上,不得在已获取 LwIP 堆栈锁的情况下调用此方法
发送消息
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.
细节 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
| ||||||||||||
返回值 |
|
发给
INET_ERROR SendTo( IPAddress addr, uint16_t port, Weave::System::PacketBuffer *msg, uint16_t sendFlags )
一种用于同义词SendTo(addr, port, INET_NULL_INTERFACEID, msg, sendFlags)
发给
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.
细节 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
| ||||||||||||
返回值 |
|