Hi,
How can I determine if a TCPSocket has been closed? I have written this tool
which acts as a proxy and displays everything that passes thru it. I have a
pop3 server running, and set my e-mail client to connect to my TCPServer
that listens on port 555. I can see the whole pop3-e-mail-check transaction.
But when the e-mail client is finished, and the pop3 server says good bye,
socket.closed? still returns false. Is it a bad idea to use the IO class
".closed?" ?
Script follows. Thanks in advance. -Lars
···
###############################################
require ‘socket’
server = TCPServer.open(‘localhost’, 555)
loop do
outlook = server.accept
socket = TCPSocket.open(‘localhost’, 110)
shouldQuit = false
Thread.new do
loop do
data = socket.sysread(500)
print data
outlook.syswrite(data)
end
end
Thread.new do
loop do
data = outlook.sysread(500)
print data
socket.syswrite(data)
end
end
while not outlook.closed?
end
socket.close
end
server.close
###############################################