Class: UDPSocket (Ruby 2.2.2)
Description: Class : UDPSocket - Ruby 2.2.2

- Home
- Core 2.2.2
- Std-lib 2.2.2
- Downloads

Support for the Ruby 2.2 series has ended. See here for reference.

### Home Classes Methods

### In Files

- resolv-replace.rb

### Parent

IPSocket

### Methods

- #bind
- #connect
- #send

### Class/Module Index

Quicksearch

- IPSocket
- SOCKSSocket
- TCPSocket
- UDPSocket

No matching classes.

# UDPSocket

### Public Instance Methods

bind(host, port) click to toggle source

                   # File resolv-replace.rb, line 31
    def bind(host, port)
      host = IPSocket.getaddress(host) if host != ""
      original_resolv_bind(host, port)
    end

connect(host, port) click to toggle source

                   # File resolv-replace.rb, line 39
    def connect(host, port)
      original_resolv_connect(IPSocket.getaddress(host), port)
    end

send(mesg, flags, *rest) click to toggle source

                   # File resolv-replace.rb, line 46
    def send(mesg, flags, *rest)
      if rest.length == 2
        host, port = rest
        begin
          addrs = Resolv.getaddresses(host)
        rescue Resolv::ResolvError
          raise SocketError, "Hostname not known: #{host}"
        end
        addrs[0...-1].each {|addr|
          begin
            return original_resolv_send(mesg, flags, addr, port)
          rescue SystemCallError
          end
        }
        original_resolv_send(mesg, flags, addrs[-1], port)
      else
        original_resolv_send(mesg, flags, *rest)
      end
    end