K
Karl-Heinz Wild
I'm playing with the class TcpServer from the
package ldap-server.
There is an interesting way for me of running a tcp server.
-----------------------------
t = GAME::Server.tcpserverport=>1110, :nodelay=>true) do
print "+OK I am a fake POP3 server\r\n"
while line = gets
case line
when /^quit/i
break
else
print "-ERR I don't understand #{line}"
end
end
print "+OK bye\r\n"
end
t.join
end
----------------------------
inside the GAME:Server.tcpserver it looks like
----------------------------
def self.tcpserver(opt, &blk)
server = TCPServer.new(opt[:bindaddr] || "0.0.0.0", opt[ort])
server.listen(opt[:listen]) if opt[:listen]
Thread.new do
while true
begin
session = server.accept
Thread.new(session) do |s|
s.instance_eval(&blk)
end
rescue Interrupt
server.close if server and not server.closed?
break
end
end
end
end
------------------------------
Now, how can I get access to the "session" variables.
I need some information from TCP inside the block.
But I couldn't find out how.
Thanks for reading the mail and maybe an answer
regards
Karl-Heinz
package ldap-server.
There is an interesting way for me of running a tcp server.
-----------------------------
t = GAME::Server.tcpserverport=>1110, :nodelay=>true) do
print "+OK I am a fake POP3 server\r\n"
while line = gets
case line
when /^quit/i
break
else
print "-ERR I don't understand #{line}"
end
end
print "+OK bye\r\n"
end
t.join
end
----------------------------
inside the GAME:Server.tcpserver it looks like
----------------------------
def self.tcpserver(opt, &blk)
server = TCPServer.new(opt[:bindaddr] || "0.0.0.0", opt[ort])
server.listen(opt[:listen]) if opt[:listen]
Thread.new do
while true
begin
session = server.accept
Thread.new(session) do |s|
s.instance_eval(&blk)
end
rescue Interrupt
server.close if server and not server.closed?
break
end
end
end
end
------------------------------
Now, how can I get access to the "session" variables.
I need some information from TCP inside the block.
But I couldn't find out how.
Thanks for reading the mail and maybe an answer
regards
Karl-Heinz