Skip to content
instance method

UDPSocket#connect

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

Connects udpsocket to host:port.

This makes possible to send without destination address.

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