Skip to content
instance method

UDPSocket#bind

(::String host, ::Integer port) -> void
udpsocket.bind(host, port) #=> 0

Binds udpsocket to host:port.

Example
u1 = UDPSocket.new
u1.bind("127.0.0.1", 4913)
u1.send "message-to-self", 0, "127.0.0.1", 4913
p u1.recvfrom(10) #=> ["message-to", ["AF_INET", 4913, "localhost", "127.0.0.1"]]
See also .new #connect #recvfrom_nonblock also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0