Created
March 16, 2009 00:22
-
-
Save davidlee/79598 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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