Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Peter Cooperx http://www.petercooper.co.uk/

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Getting a client's IP address with EventMachine

This is from, and by: http://nhw.pl/wp/2007/12/07/eventmachine-how-to-get-clients-ip-address/ .. I just wanted a more permanent reference as it's cool code.

   1  
   2  EventMachine::run {
   3     EventMachine::open_datagram_socket $conf[:address],
   4                                   $conf[:udp_port], CustomServer
   5  }
   6  
   7  module CustomServer
   8     def receive_data d
   9        pp get_peername[2,6].unpack "nC4"
  10     end
  11  end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS