Here’s a time server implementation that you can know by heart:
time_server_channel = Cod.tcp_server('10.0.0.2:4444')
loop do
request, client_channel = time_server_channel.get_ext
case request
when :time
client_channel.put Time.now
when :date
client_channel.put Date.today
else
client_channel.put 'Unknown request!'
end
client_channel.close
end
Here’s the client:
time_chan = Cod.tcp('10.0.0.2:4444')
time = time_chan.interact(:time)
puts "At the next clock cycle, it is #{time}."
Some.
Here’s the who’s who of the cod universe. This is what you see in the navigation bar as well.
Here, have some YARD documentation as a side dish.
Don’t read the source code. There, I’ve warned you.
Please:
Remember: I test my code, so you should too. Please include relevant rspec tests in all pull requests.
Thanks to all contributors!
cod and associated products (this website) are under an MIT license (see LICENSE file). The cod image is copyright by the Norwegian Institute of Marine Research – thanks for letting us use it!
Need help with some hairy Ruby problems? Maybe an astronaut can show you how to get to safe ground.