#!/usr/bin/env ruby require 'rubygems' require 'eventmachine' module PongServer def post_init puts "client connected!" end def receive_data(data) p data p get_peername[2,6].unpack "nC4" send_data "pong\n" end end EM.run do # EventMachine.epoll EM.open_datagram_socket '0.0.0.0', 3178, PongServer puts 'running Pong on port 3178' end