Hi guys,
So, now that GCD sources are supported (go Ernie!), I just thought I'd play
with a simple echo server example in MacRuby:
require 'socket'
q = Dispatch::Queue.concurrent
m = Dispatch::Queue.main
hostname = "localhost"
port = 25000
s = TCPServer.open(hostname, port)
src = Dispatch::Source.new(Dispatch::Source::READ, s, 0, q) { |src|
client = s.accept # XXX Would like to actually get this from src,
rather than grabbing the server socket object directly
client.puts(Time.now.ctime)
client.puts "Closing down, Bunkie!"
client.close
}
m.run
The line with the XXX is the issue I'm trying to figure out. If I look at
src.handle or src.data, I end up getting an integer which looks like a fd, not
the original TCPSocket instance I passed in, which means I can't call the
accept method on it. Is there some secret to getting at the original handle?
Thanks!
- Jordan
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel