Skip to content
class method

UDPSocket.new

(?::Integer family) -> ::UDPSocket
UDPSocket.new([address_family]) => socket

Creates a new UDPSocket object.

address_family should be an integer, a string or a symbol: Socket::AF_INET, “AF_INET”, :INET, etc.

Example
require 'socket'

UDPSocket.new                   #=> #<UDPSocket:fd 3>
UDPSocket.new(Socket::AF_INET6) #=> #<UDPSocket:fd 4>
See also #bind #connect also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0