Class: Ftpd::Server
Direct Known Subclasses
Instance Attribute Summary collapse
-
#interface ⇒ Object
The interface to bind to (e.g. “127.0.0.1”, “0.0.0.0”, “10.0.0.12”, etc.).
-
#port ⇒ Object
The port to bind to.
Instance Method Summary collapse
-
#bound_port ⇒ Object
The port the server is bound to.
-
#initialize ⇒ Server
constructor
A new instance of Server.
-
#start ⇒ Object
Start the server.
-
#stop ⇒ Object
Stop the server.
Constructor Details
#initialize ⇒ Server
Returns a new instance of Server.
19 20 21 22 |
# File 'lib/ftpd/server.rb', line 19 def initialize @interface = 'localhost' @port = 0 end |
Instance Attribute Details
#interface ⇒ Object
The interface to bind to (e.g. “127.0.0.1”, “0.0.0.0”, “10.0.0.12”, etc.). Defaults to “localhost” Changes made after #start have no effect.
10 11 12 |
# File 'lib/ftpd/server.rb', line 10 def interface @interface end |
#port ⇒ Object
The port to bind to. Defaults to 0, which causes an ephemeral port to be used. When bound to an ephemeral port, use #bound_port to find out which port was actually bound to. Changes made after #start have no effect.
17 18 19 |
# File 'lib/ftpd/server.rb', line 17 def port @port end |
Instance Method Details
#bound_port ⇒ Object
The port the server is bound to. Must not be called until after #start is called.
27 28 29 |
# File 'lib/ftpd/server.rb', line 27 def bound_port @server_socket.addr[1] end |
#start ⇒ Object
Start the server. This creates the server socket, and the thread to service it.
34 35 36 37 |
# File 'lib/ftpd/server.rb', line 34 def start @server_socket = make_server_socket @server_thread = make_server_thread end |
#stop ⇒ Object
Stop the server. This closes the server socket, which in turn stops the thread.
42 43 44 |
# File 'lib/ftpd/server.rb', line 42 def stop @server_socket.close end |