How does one set the TOS flags/DSCP flags in Ruby on a UDP/TCP stream (preferably using the Ruby/Sockets library)?
A:
Try Socket#setsockoption(). Its documented in Appendix A of the pickaxe book, or you can browse the source for interface details.
-- MarkusQ
MarkusQ
2009-03-03 21:37:02
+1
A:
You can set the TOS flags with Socket#setsockopt passing IPPROTO_IP
as the level, IP_TOP
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)
jgre
2009-05-21 18:59:04
This works on Linux. Thanks so far, but would there also be something similar for Windows?
Deadolus
2009-06-15 11:26:18
I'm sorry, I've never worked with windows sockets.
jgre
2009-06-18 06:29:11