Skip to content
instance method

Addrinfo#bind

() -> ::Socket
() { (::Socket) -> void } -> void
bind() { |sock| ... }

creates a socket bound to self.

If a block is given, it is called with the socket and the value of the block is returned. The socket is returned otherwise.

Example
Addrinfo.udp("0.0.0.0", 9981).bind {|s|
  s.local_address.connect {|s| s.send "hello", 0 }
  p s.recv(10) #=> "hello"
}
See also #afamily #canonname .unix #connect also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0