connected UDP objects 帮看下 多谢~!

54 views
Skip to first unread message

yiliaofan

unread,
Aug 22, 2019, 12:42:32 AM8/22/19
to openresty
@春哥 好~

connected:setpeername('*')

unconnected:setpeername(address, port)

Changes the peer of a UDP object. This method turns an unconnected UDP object into a connected UDP object or vice versa.

For connected objects, outgoing datagrams will be sent to the specified peer, and datagrams received from other peers will be discarded by the OS. Connected UDP objects must use the send and receive methods instead of sendto and receivefrom.

Address can be an IP address or a host name. Port is the port number. If address is '*' and the object is connected, the peer association is removed and the object becomes an unconnected object again. In that case, the port argument is ignored.

In case of error the method returns nil followed by an error message. In case of success, the method returns 1.

Note: Since the address of the peer does not have to be passed to and from the OS, the use of connected UDP objects is recommended when the same peer is used for several transmissions and can result in up to 30% performance gains.


是否可以这么处理:
1、 rewrite_by_lua*, access_by_lua* 阶段,通过ngx.udp(),setpeername('/tmp/udp.sock') 实现共享udp连接?
2、
result in up to 30% performance 30%的性能提升,是这种处理方式么? 

多谢~!

yiliaofan

unread,
Sep 3, 2019, 12:07:44 AM9/3/19
to openresty
关于udp 如何能做到复用fd呢?如何提高udp性能 ? 

非常感谢~!



在 2019年8月22日星期四 UTC+8下午12:42:32,yiliaofan写道:
Reply all
Reply to author
Forward
0 new messages