Class: Sprout::FCSHSocket
- Inherits:
-
Object
- Object
- Sprout::FCSHSocket
- Defined in:
- lib/sprout/fcsh_socket.rb
Class Method Summary collapse
Class Method Details
.execute(command, port = 12321) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sprout/fcsh_socket.rb', line 21 def self.execute(command, port=12321) session = TCPSocket.new('localhost', port) session.puts(command) response = session.read error = response =~ /(.*Error:.*\^.*)\n/m if(error) raise FCSHError.new(response) end session.close return response end |
.server(port = 12321, out = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sprout/fcsh_socket.rb', line 8 def self.server(port=12321, out=nil) out = out || $stdout server = TCPServer.new(port) @fcsh = FCSHService.new(out) out.puts ">> fcsh started, waiting for connections on port #{port}" while(session = server.accept) response = @fcsh.execute(session.gets) session.puts(response) session.flush session.close end end |