Module: Rex::IO::GramServer
- Included in:
- Proto::DNS::Server, Proto::LDAP::Server
- Defined in:
- lib/rex/io/gram_server.rb
Overview
This mixin provides the framework and interface for implementing a datagram server that can handle incoming datagrams. Datagram servers include this mixin
Instance Attribute Summary collapse
-
#dispatch_request_proc ⇒ Object
This callback procedure can be set and will be called when clients have data to be processed.
-
#listener_thread ⇒ Object
:nodoc:.
-
#send_response_proc ⇒ Object
This callback procedure can be set and will be called when clients have data to be processed.
Instance Method Summary collapse
-
#dispatch_request(client, data) ⇒ Object
This callback is notified when a client connection has data that needs to be processed.
-
#send_response(client, data) ⇒ Object
This callback is notified when data must be returned to the client.
-
#start ⇒ Object
Start monitoring the listener socket for connections and keep track of all client connections.
-
#stop ⇒ Object
Terminates the listener monitoring threads and closes all active clients.
-
#wait ⇒ Object
This method waits on the server listener thread.
Instance Attribute Details
#dispatch_request_proc ⇒ Object
This callback procedure can be set and will be called when clients have data to be processed.
85 86 87 |
# File 'lib/rex/io/gram_server.rb', line 85 def dispatch_request_proc @dispatch_request_proc end |
#listener_thread ⇒ Object
:nodoc:
87 88 89 |
# File 'lib/rex/io/gram_server.rb', line 87 def listener_thread @listener_thread end |
#send_response_proc ⇒ Object
This callback procedure can be set and will be called when clients have data to be processed.
85 86 87 |
# File 'lib/rex/io/gram_server.rb', line 85 def send_response_proc @send_response_proc end |
Instance Method Details
#dispatch_request(client, data) ⇒ Object
This callback is notified when a client connection has data that needs to be processed.
33 34 35 36 37 |
# File 'lib/rex/io/gram_server.rb', line 33 def dispatch_request(client, data) if (dispatch_request_proc) dispatch_request_proc.call(client, data) end end |
#send_response(client, data) ⇒ Object
This callback is notified when data must be returned to the client
43 44 45 46 47 48 49 |
# File 'lib/rex/io/gram_server.rb', line 43 def send_response(client, data) if (send_response_proc) send_response_proc.call(client, data) else client.write(data) end end |
#start ⇒ Object
Start monitoring the listener socket for connections and keep track of all client connections.
55 56 57 58 59 |
# File 'lib/rex/io/gram_server.rb', line 55 def start self.listener_thread = Rex::ThreadFactory.spawn("GramServerListener", false) { monitor_listener } end |
#stop ⇒ Object
Terminates the listener monitoring threads and closes all active clients.
64 65 66 |
# File 'lib/rex/io/gram_server.rb', line 64 def stop self.listener_thread.kill end |
#wait ⇒ Object
This method waits on the server listener thread
71 72 73 |
# File 'lib/rex/io/gram_server.rb', line 71 def wait self.listener_thread.join if self.listener_thread end |