Module: SocketMessage
- Defined in:
- lib/minitcp.rb
Overview
messages stream
Instance Method Summary collapse
Instance Method Details
#on_message(timeout = nil, &b) ⇒ Object
359 360 361 362 363 364 365 366 367 |
# File 'lib/minitcp.rb', line 359 def (timeout=nil,&b) on_n_receive(6) do |head| len=head.to_i received_n_timeout(len,10_000) do |data| response=b.call(eval(data)) send(response) if response end end end |
#send_message(message) ⇒ Object
368 369 370 371 |
# File 'lib/minitcp.rb', line 368 def () data=.inspect send(("%6d" % data.size)+data,0) end |