How to do TOS/DSCP in ruby?

好久不见. 提交于 2019-12-11 04:16:30

问题


How does one set the TOS flags/DSCP flags in Ruby on a UDP/TCP stream (preferably using the Ruby/Sockets library)?


回答1:


You can set the TOS flags with Socket.setsockopt passing IPPROTO_IP as the level, IP_TOS as the name of the option, and your desired value:

require 'socket'
s = TCPSocket.new('example.com', 80)
s.setsockopt(Socket::IPPROTO_IP, Socket::IP_TOS, YOUR_TOS_VAL)



回答2:


Try Socket#setsockoption(). Its documented in Appendix A of the pickaxe book, or you can browse the source for interface details.

-- MarkusQ



来源:https://stackoverflow.com/questions/608286/how-to-do-tos-dscp-in-ruby

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!