1

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

Community
  • 1
  • 1
Deadolus
  • 372
  • 3
  • 17

2 Answers2

2

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)
zwierzak
  • 269
  • 1
  • 4
  • 12
jgre
  • 787
  • 5
  • 11
0

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

-- MarkusQ

MarkusQ
  • 21,814
  • 3
  • 56
  • 68