Sha256: e4d76dee9cfc0a01b879c1e3d1912d55f430132c3c16426c44c294ffd89db519
Contents?: true
Size: 623 Bytes
Versions: 3
Compression:
Stored size: 623 Bytes
Contents
#!/usr/bin/env ruby require 'eventmachine' module EchoServer def post_init p 'post_init' end def connection_completed p 'connection_completed' end def receive_data data send_data ">>>you sent: #{data}" close_connection if data =~ /quit/i end def unbind p 'unbind' end end def get_port_for_fd(fd) sockname = EM.get_sockname(fd) port, host = Socket.unpack_sockaddr_in(sockname) port end # Note that this will block current thread. EventMachine.run { fd = EventMachine.start_server "127.0.0.1", 0, EchoServer do |e| p e end p get_port_for_fd(fd) }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ftpd-0.2.0 | sandbox/em-server.rb |
ftpd-0.1.1 | sandbox/em-server.rb |
ftpd-0.1.0 | sandbox/em-server.rb |