W
Walle Wallen
I got a question regarding threads and the function gets. Lets say I got
two threads running simultaneously. Both are reading from the same
TCPSocket. Will the threads be able to read from the same TCPSocket at
the same time, or will the first thread lock it from the other.
Example code
two threads running simultaneously. Both are reading from the same
TCPSocket. Will the threads be able to read from the same TCPSocket at
the same time, or will the first thread lock it from the other.
Example code
Code:
def user_idle_time(connection, name, conn)
Timeout::timeout(3.5) do
connection.send("whois #{name} #{name} \r\n", 0)
while server_response = connection.gets
if(server_response.split(" ")[1].to_i == 317)
return conn["Factotum"].seconds_to_hms(server_response.split("
")[4].to_i)
else
@cached_messages << server_response
end
end
end
rescue Timeout::Error
return "Unknown"
end