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-2 of 2 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.

EventMachine::run {
   EventMachine::open_datagram_socket $conf[:address],
                                 $conf[:udp_port], CustomServer
}

module CustomServer
   def receive_data d
      pp get_peername[2,6].unpack "nC4"
   end
end
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS