Sha256: dd474356dd1d53aa6e5959a3977f56c695c1d9c1b2ef86737a375275c6482956
Contents?: true
Size: 714 Bytes
Versions: 5
Compression:
Stored size: 714 Bytes
Contents
require File.dirname(__FILE__) + '/../lib/rev' ADDR = '127.0.0.1' PORT = 4321 class ClientConnection < Rev::TCPSocket def on_connect puts "#{remote_addr}:#{remote_port} connected" write "bounce this back to me" end def on_close puts "#{remote_addr}:#{remote_port} disconnected" end def on_read(data) print "got #{data}" close end def on_resolve_failed print "DNS resolve failed" end def on_connect_failed print "connect failed, meaning our connection to their port was rejected" end end event_loop = Rev::Loop.default client = ClientConnection.connect(ADDR, PORT) client.attach(event_loop) puts "Echo client connecting to #{ADDR}:#{PORT}..." event_loop.run
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
rev-0.3.2 | examples/echo_client.rb |
rev-0.3.1 | examples/echo_client.rb |
rev-0.3.0 | examples/echo_client.rb |
rev-0.2.3 | examples/echo_client.rb |
rev-0.2.4 | examples/echo_client.rb |