Class: EventMachine::DNS::Socket

### Home Classes Methods

### In Files

- lib/em/resolver.rb

### Parent

EventMachine::Connection

### Methods

- ::new
- ::open
- #nameserver
- #nameserver=
- #post_init
- #receive_data
- #register_request
- #send_packet
- #tick
- #unbind

### Files

- ChangeLog
- DEFERRABLES
- EPOLL
- INSTALL
- KEYBOARD
- LEGAL
- LIGHTWEIGHT_CONCURRENCY
- PURE_RUBY
- RELEASE_NOTES
- SMTP
- SPAWNED_PROCESSES
- TODO

### Class/Module Index

Quicksearch

- EventMachine
- EventMachine
- EventMachine::Channel
- EventMachine::Completion
- EventMachine::Connection
- EventMachine::DNS
- EventMachine::DNS::Request
- EventMachine::DNS::RequestIdAlreadyUsed
- EventMachine::DNS::Resolver
- EventMachine::DNS::Socket
- EventMachine::DatagramObject
- EventMachine::DefaultDeferrable
- EventMachine::Deferrable
- EventMachine::DeferrableChildProcess
- EventMachine::Error
- EventMachine::EvmaKeyboard
- EventMachine::EvmaTCPClient
- EventMachine::EvmaTCPServer
- EventMachine::EvmaUDPSocket
- EventMachine::EvmaUNIXClient
- EventMachine::EvmaUNIXServer
- EventMachine::FileNotFoundException
- EventMachine::FileStreamer
- EventMachine::FileWatch
- EventMachine::Iterator
- EventMachine::LoopbreakReader
- EventMachine::PeriodicTimer
- EventMachine::Pool
- EventMachine::ProcessWatch
- EventMachine::Protocols
- EventMachine::Protocols
- EventMachine::Protocols::HeaderAndContentProtocol
- EventMachine::Protocols::HttpClient
- EventMachine::Protocols::HttpClient2
- EventMachine::Protocols::HttpClient2::Request
- EventMachine::Protocols::LineAndTextProtocol
- EventMachine::Protocols::LineProtocol
- EventMachine::Protocols::LineText2
- EventMachine::Protocols::Memcache
- EventMachine::Protocols::Memcache::ParserError
- EventMachine::Protocols::ObjectProtocol
- EventMachine::Protocols::Postgres3
- EventMachine::Protocols::SASLauth
- EventMachine::Protocols::SASLauthclient
- EventMachine::Protocols::SmtpClient
- EventMachine::Protocols::SmtpServer
- EventMachine::Protocols::Socks4
- EventMachine::Protocols::Stomp
- EventMachine::Protocols::Stomp::Message
- EventMachine::Protocols::TcpConnectTester
- EventMachine::Queue
- EventMachine::Reactor
- EventMachine::Selectable
- EventMachine::SpawnedProcess
- EventMachine::StreamObject
- EventMachine::SystemCmd
- EventMachine::ThreadedResource
- EventMachine::TickLoop
- EventMachine::Timer
- EventMachine::UuidGenerator
- EventMachine::YieldBlockFromSpawnedProcess
- Object
- Object::EM
- Object::P
- BufferedTokenizer
- IO
- StringIO
- TestConnection

No matching classes.

# EventMachine::DNS::Socket

### Public Class Methods

new() click to toggle source

    # File lib/em/resolver.rb, line 63
    def initialize
      @nameserver = nil
    end

open() click to toggle source

    # File lib/em/resolver.rb, line 59
    def self.open
      EventMachine::open_datagram_socket('0.0.0.0', 0, self)
    end

### Public Instance Methods

nameserver() click to toggle source

    # File lib/em/resolver.rb, line 97
    def nameserver
      @nameserver || Resolver.nameserver
    end

nameserver=(ns) click to toggle source

    # File lib/em/resolver.rb, line 93
    def nameserver=(ns)
      @nameserver = ns
    end

post_init() click to toggle source

    # File lib/em/resolver.rb, line 67
    def post_init
      @requests = {}
      EM.add_periodic_timer(0.1, &method(:tick))
    end

receive_data(data) click to toggle source

Decodes the packet, looks for the request and passes the response over to the requester

    # File lib/em/resolver.rb, line 103
    def receive_data(data)
      msg = nil
      begin
        msg = Resolv::DNS::Message.decode data
      rescue
      else
        req = @requests[msg.id]
        if req
          @requests.delete(msg.id)
          req.receive_answer(msg)
        end
      end
    end

register_request(id, req) click to toggle source

    # File lib/em/resolver.rb, line 81
    def register_request(id, req)
      if @requests.has_key?(id)
        raise RequestIdAlreadyUsed
      else
        @requests[id] = req
      end
    end

send_packet(pkt) click to toggle source

    # File lib/em/resolver.rb, line 89
    def send_packet(pkt)
      send_datagram(pkt, nameserver, 53)
    end

tick() click to toggle source

    # File lib/em/resolver.rb, line 75
    def tick
      @requests.each do |id,req|
        req.tick
      end
    end

unbind() click to toggle source

    # File lib/em/resolver.rb, line 72
    def unbind
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.