Skip to content

Instantly share code, notes, and snippets.

@davidlee
Created March 16, 2009 00:22
Show Gist options
  • Save davidlee/79598 to your computer and use it in GitHub Desktop.
Save davidlee/79598 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'eventmachine'
module Socky
module Policy
DEBUG = true
HOST = 'localhost'
PORT = 843
EOF = "\r\000"
REQUEST = "<policy-file-request/>\000"
DOCUMENT = File.read(FIle.join(File.dirname(__FILE__),'policy.xml'))
module Server
def receive_data(data)
if DEBUG
if data == REQUEST
STDERR.putc( "." );
else
STDERR.puts( "\n[ Malformed request: #{ data } ]" )
end
end
send_data( DOCUMENT )
end
end
end
end
if __FILE__ == $0
EventMachine::run do
EventMachine::start_server( Socky::Policy::HOST,
Socky::Policy::PORT,
Socky::Policy::Server )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment