Last active
November 13, 2015 17:27
-
-
Save yorickpeterse/7e8677207ef28f8df10f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
server = Socket.new(:INET, :DGRAM) | |
client = Socket.new(:INET, :DGRAM) | |
server.bind(Socket.sockaddr_in(0, '127.0.0.1')) | |
client.connect(Socket.sockaddr_in(server.connect_address.ip_port, '127.0.0.1')) | |
client.write('hello world how are you doing') | |
msg, addr, flags, *controls = server.recvmsg | |
found = Socket.constants.grep(/^MSG_/).map do |name| | |
flags & Socket.const_get(name) | |
end | |
p flags # => 1073741824 | |
p found # => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment