Skip to content

Instantly share code, notes, and snippets.

@Hexa
Created September 6, 2012 12:39
Show Gist options
  • Select an option

  • Save Hexa/3655826 to your computer and use it in GitHub Desktop.

Select an option

Save Hexa/3655826 to your computer and use it in GitHub Desktop.
require 'socket'
sock4 = UDPSocket.new(Socket::AF_INET)
sock4.bind('0.0.0.0', 40000) # => 0
sock6 = UDPSocket.new(Socket::AF_INET6)
sock6.bind('::', 40000) # =>Errno::EADDRINUSE: Address already in use - bind(2)
sock6.setsockopt(Socket::IPPROTO_IPV6, Socket::IPV6_V6ONLY, true)
sock6.bind('::', 40000) # => 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment