ruby使用UDPSocket的recvfrom方法,通信变得很慢

When doing data, addr = @socket.recvfrom(1500), the addr array contains Array: ["AF_INET", port, "resolved-name-or-ip", "ip"]


How can I disable resolving on UDPSocket? The documentation for ruby UDPSocket is bit poor.

Ok. I found it.


I'll document this here so someone might get lucky and find it.


To disable automatic lookups, put this in your code:


BasicSocket.do_not_reverse_lookup = true


before you create the socket. It does the trick.


你可能感兴趣的:(lookup,slow,recvfrom,UDPSocket)