Module: Ronin::Network::Mixins::UDP
Overview
Adds UDP convenience methods and connection parameters to a class.
Defines the following parameters:
host(String) - UDP host.port(Integer) - UDP port.local_host(String) - UDP local host.local_port(Integer) - UDP local port.server_host(String) - UDP server host.server_port(Integer) - UDP server port.
Class Method Summary (collapse)
-
+ (Object) host
UDP host.
-
+ (Object) host=(value)
UDP host.
-
+ (Object) local_host
UDP local host.
-
+ (Object) local_host=(value)
UDP local host.
-
+ (Object) local_port
UDP local port.
-
+ (Object) local_port=(value)
UDP local port.
-
+ (Object) port
UDP port.
-
+ (Object) port=(value)
UDP port.
-
+ (Object) server_host
UDP server host.
-
+ (Object) server_host=(value)
UDP server host.
-
+ (Object) server_port
UDP server port.
-
+ (Object) server_port=(value)
UDP server port.
Instance Method Summary (collapse)
-
- (Object) host
UDP host.
-
- (Object) host=(value)
UDP host.
-
- (Object) local_host
UDP local host.
-
- (Object) local_host=(value)
UDP local host.
-
- (Object) local_port
UDP local port.
-
- (Object) local_port=(value)
UDP local port.
-
- (Object) port
UDP port.
-
- (Object) port=(value)
UDP port.
-
- (Object) server_host
UDP server host.
-
- (Object) server_host=(value)
UDP server host.
-
- (Object) server_port
UDP server port.
-
- (Object) server_port=(value)
UDP server port.
-
- (UDPSocket) udp_connect {|socket| ... }
protected
Opens a UDP connection to the host and port specified by the
hostandportparameters. -
- (UDPSocket) udp_connect_and_send(data) {|socket| ... }
protected
Connects to the host and port specified by the
hostandportparameters, then sends the given data. -
- (Boolean?) udp_open?(timeout = nil)
protected
Tests whether the UDP port, specified by the
hostandportparameters, is open. -
- (nil) udp_recv {|server, (client_host, client_port), mesg| ... }
protected
Creates a new UDPServer listening on the
server_hostandserver_portparameters, accepts only one message from a client. -
- (true) udp_send(data)
protected
Connects to the host and port specified by the
hostandportparameters, sends the given data and then disconnects. -
- (UDPServer) udp_server {|server| ... }
protected
Creates a new UDPServer object listening on
server_hostandserver_portparameters. -
- (nil) udp_server_loop {|server, (client_host, client_port), mesg| ... }
protected
Creates a new UDPServer listening on the
server_hostandserver_portparameters, accepting messages from clients in a loop. -
- (nil) udp_server_session {|server| ... }
protected
Creates a new temporary UDPServer object listening on the
server_hostandserver_portparameters. -
- (nil) udp_session {|socket| ... }
protected
Creates a UDP session to the host and port specified by the
hostandportparameters. -
- (Object) udp_single_server(&block)
protected
deprecated
Deprecated.
Deprecated as of 0.5.0. Use #udp_recv instead.
Methods included from Mixin
Methods included from UDP
Class Method Details
+ (Object) host
UDP host
42 43 |
# File 'lib/ronin/network/mixins/udp.rb', line 42 parameter :host, :type => String, :description => 'UDP host' |
+ (Object) host=(value)
UDP host
42 43 |
# File 'lib/ronin/network/mixins/udp.rb', line 42 parameter :host, :type => String, :description => 'UDP host' |
+ (Object) local_host
UDP local host
50 51 |
# File 'lib/ronin/network/mixins/udp.rb', line 50 parameter :local_host, :type => String, :description => 'UDP local host' |
+ (Object) local_host=(value)
UDP local host
50 51 |
# File 'lib/ronin/network/mixins/udp.rb', line 50 parameter :local_host, :type => String, :description => 'UDP local host' |
+ (Object) local_port
UDP local port
54 55 |
# File 'lib/ronin/network/mixins/udp.rb', line 54 parameter :local_port, :type => Integer, :description => 'UDP local port' |
+ (Object) local_port=(value)
UDP local port
54 55 |
# File 'lib/ronin/network/mixins/udp.rb', line 54 parameter :local_port, :type => Integer, :description => 'UDP local port' |
+ (Object) port
UDP port
46 47 |
# File 'lib/ronin/network/mixins/udp.rb', line 46 parameter :port, :type => Integer, :description => 'UDP port' |
+ (Object) port=(value)
UDP port
46 47 |
# File 'lib/ronin/network/mixins/udp.rb', line 46 parameter :port, :type => Integer, :description => 'UDP port' |
+ (Object) server_host
UDP server host
58 59 |
# File 'lib/ronin/network/mixins/udp.rb', line 58 parameter :server_host, :type => String, :description => 'UDP server host' |
+ (Object) server_host=(value)
UDP server host
58 59 |
# File 'lib/ronin/network/mixins/udp.rb', line 58 parameter :server_host, :type => String, :description => 'UDP server host' |
+ (Object) server_port
UDP server port
62 63 |
# File 'lib/ronin/network/mixins/udp.rb', line 62 parameter :server_port, :type => Integer, :description => 'UDP server port' |
+ (Object) server_port=(value)
UDP server port
62 63 |
# File 'lib/ronin/network/mixins/udp.rb', line 62 parameter :server_port, :type => Integer, :description => 'UDP server port' |
Instance Method Details
- (Object) host
UDP host
42 43 |
# File 'lib/ronin/network/mixins/udp.rb', line 42 parameter :host, :type => String, :description => 'UDP host' |
- (Object) host=(value)
UDP host
42 43 |
# File 'lib/ronin/network/mixins/udp.rb', line 42 parameter :host, :type => String, :description => 'UDP host' |
- (Object) local_host
UDP local host
50 51 |
# File 'lib/ronin/network/mixins/udp.rb', line 50 parameter :local_host, :type => String, :description => 'UDP local host' |
- (Object) local_host=(value)
UDP local host
50 51 |
# File 'lib/ronin/network/mixins/udp.rb', line 50 parameter :local_host, :type => String, :description => 'UDP local host' |
- (Object) local_port
UDP local port
54 55 |
# File 'lib/ronin/network/mixins/udp.rb', line 54 parameter :local_port, :type => Integer, :description => 'UDP local port' |
- (Object) local_port=(value)
UDP local port
54 55 |
# File 'lib/ronin/network/mixins/udp.rb', line 54 parameter :local_port, :type => Integer, :description => 'UDP local port' |
- (Object) port
UDP port
46 47 |
# File 'lib/ronin/network/mixins/udp.rb', line 46 parameter :port, :type => Integer, :description => 'UDP port' |
- (Object) port=(value)
UDP port
46 47 |
# File 'lib/ronin/network/mixins/udp.rb', line 46 parameter :port, :type => Integer, :description => 'UDP port' |
- (Object) server_host
UDP server host
58 59 |
# File 'lib/ronin/network/mixins/udp.rb', line 58 parameter :server_host, :type => String, :description => 'UDP server host' |
- (Object) server_host=(value)
UDP server host
58 59 |
# File 'lib/ronin/network/mixins/udp.rb', line 58 parameter :server_host, :type => String, :description => 'UDP server host' |
- (Object) server_port
UDP server port
62 63 |
# File 'lib/ronin/network/mixins/udp.rb', line 62 parameter :server_port, :type => Integer, :description => 'UDP server port' |
- (Object) server_port=(value)
UDP server port
62 63 |
# File 'lib/ronin/network/mixins/udp.rb', line 62 parameter :server_port, :type => Integer, :description => 'UDP server port' |
- (UDPSocket) udp_connect {|socket| ... } (protected)
Opens a UDP connection to the host and port specified by the
host and port parameters. If the local_host and
local_port parameters are set, they will be used for
the local host and port of the UDP connection.
116 117 118 119 120 |
# File 'lib/ronin/network/mixins/udp.rb', line 116 def udp_connect(&block) print_info "Connecting to #{host_port} ..." return super(self.host,self.port,self.local_host,self.local_port,&block) end |
- (UDPSocket) udp_connect_and_send(data) {|socket| ... } (protected)
Connects to the host and port specified by the host and port
parameters, then sends the given data. If the local_host and
local_port instance methods are set, they will be used for the
local host and port of the UDP connection.
144 145 146 147 148 149 |
# File 'lib/ronin/network/mixins/udp.rb', line 144 def udp_connect_and_send(data,&block) print_info "Connecting to #{host_port} ..." print_debug "Sending data: #{data.inspect}" return super(data,self.host,self.port,self.local_host,self.local_port,&block) end |
- (Boolean?) udp_open?(timeout = nil) (protected)
Tests whether the UDP port, specified by the host and port
parameters, is open.
82 83 84 85 86 |
# File 'lib/ronin/network/mixins/udp.rb', line 82 def udp_open?(timeout=nil) print_info "Testing if #{host_port} is open ..." super(self.host,self.port,self.local_host,self.local_port,timeout) end |
- (nil) udp_recv {|server, (client_host, client_port), mesg| ... } (protected)
Creates a new UDPServer listening on the server_host and
server_port parameters, accepts only one message from a client.
339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/ronin/network/mixins/udp.rb', line 339 def udp_recv(&block) print_info "Listening on #{self.server_host_port} ..." super(self.server_port,self.server_host) do |server,(host,port),mesg| print_info "Received message from #{host}:#{port}" print_debug mesg yield server, [host, port], mesg if block_given? end print_info "Closed #{self.server_host_port}" return nil end |
- (true) udp_send(data) (protected)
Connects to the host and port specified by the host and port
parameters, sends the given data and then disconnects.
197 198 199 200 201 202 203 204 205 |
# File 'lib/ronin/network/mixins/udp.rb', line 197 def udp_send(data) print_info "Connecting to #{host_port} ..." print_debug "Sending data: #{data.inspect}" super(data,self.host,self.port,self.local_host,self.local_port) print_info "Disconnected from #{host_port}" return true end |
- (UDPServer) udp_server {|server| ... } (protected)
Creates a new UDPServer object listening on server_host and
server_port parameters.
227 228 229 230 231 |
# File 'lib/ronin/network/mixins/udp.rb', line 227 def udp_server(&block) print_info "Listening on #{server_host_port} ..." return super(self.server_port,self.server_host,&block) end |
- (nil) udp_server_loop {|server, (client_host, client_port), mesg| ... } (protected)
Creates a new UDPServer listening on the server_host and
server_port parameters, accepting messages from clients in a loop.
297 298 299 300 301 302 303 304 |
# File 'lib/ronin/network/mixins/udp.rb', line 297 def udp_server_loop(&block) print_info "Listening on #{self.server_host_port} ..." super(self.server_port,self.server_host,&block) print_info "Closed #{self.server_host_port}" return nil end |
- (nil) udp_server_session {|server| ... } (protected)
Creates a new temporary UDPServer object listening on the
server_host and server_port parameters.
255 256 257 258 259 260 261 262 |
# File 'lib/ronin/network/mixins/udp.rb', line 255 def udp_server_session(&block) print_info "Listening on #{self.server_host_port} ..." super(self.server_port,self.server_host,&block) print_info "Closed #{self.server_host_port}" return nil end |
- (nil) udp_session {|socket| ... } (protected)
Creates a UDP session to the host and port specified by the
host and port parameters. If the local_host and local_port
parameters are set, they will be used for the local host and port
of the UDP connection.
170 171 172 173 174 175 176 177 |
# File 'lib/ronin/network/mixins/udp.rb', line 170 def udp_session(&block) print_info "Connecting to #{host_port} ..." super(self.host,self.port,self.local_host,self.local_port,&block) print_info "Disconnected from #{host_port}" return nil end |