Class: AppProfiler::Server::ProfileServer::TCP
- Defined in:
- lib/app_profiler/server.rb
Constant Summary collapse
- SERVER_ADDRESS =
it is ONLY safe to run this bound to localhost
"127.0.0.1"
Instance Attribute Summary
Attributes inherited from Transport
Instance Method Summary collapse
- #client ⇒ Object
-
#initialize(port = 0) ⇒ TCP
constructor
A new instance of TCP.
- #stop ⇒ Object
Constructor Details
#initialize(port = 0) ⇒ TCP
Returns a new instance of TCP.
169 170 171 172 173 174 175 |
# File 'lib/app_profiler/server.rb', line 169 def initialize(port = 0) super() FileUtils.mkdir_p(PROFILER_TEMPFILE_PATH) @socket = TCPServer.new(SERVER_ADDRESS, port) @port = @socket.addr[1] @port_file = Tempfile.new("profileserver-#{Process.pid}-port-#{@port}-", PROFILER_TEMPFILE_PATH) end |
Instance Method Details
#client ⇒ Object
177 178 179 |
# File 'lib/app_profiler/server.rb', line 177 def client TCPSocket.new(SERVER_ADDRESS, @port) end |
#stop ⇒ Object
181 182 183 184 |
# File 'lib/app_profiler/server.rb', line 181 def stop @port_file.unlink @socket.close end |