Hi all,

This is a very simple cmd fortune server-client (runs locally) using 'socket'.
I got some fortunes form the example of fortune server at Qt4 docs.
Here you are (change the port as you want!

).
Server:
# a simple fortune server
# author: abdelrahman ghanem
## i got some fortunes form Qt4 docs
## and some form the net
require 'socket'
fortunes = ["You've been leading a dog's life. Stay off the furniture.",
"You've got to think about tomorrow.",
"You will be surprised by a loud noise.",
"You will feel hungry again in another hour.",
"You might have mail.",
"You cannot kill time without injuring eternity.",
"Computers are not intelligent. They only think they are.",
"Behind every able man is an able woman.",
"Speak only well of people and you need never whisper",
"Promotion coming soon",
"Every man is a volum if you know how to read him",
"A good time to start something new",
"Never trouble trouble till trouble troubles you",
"You never hesitate to tackle the most difficult problems",
"The road to knowledge begins with the turn of the page",
"Answer just what yor heart prompts you",]
begin
idx = 0
server = TCPServer.open 5555
puts "Server is running at port ----> #{5555}, Now run the client."
cl=server.accept
loop do
cl.puts fortunes[idx]
if idx < fortunes.length-1
idx += 1
elsif idx == fortunes.length-1
idx = 0
end
end
rescue Exception => e
puts e.message
end
Client:
# a simple fortune client
# author: abdelrahman ghanem
require 'socket'
begin
cl = TCPSocket.open("localhost", 5555)
loop do
print "Get furtune? [Hit Enter=Get/Q=Quit]: "
rep = gets.downcase
if rep == "\n"
puts cl.gets
elsif rep == "q\n"
exit 0
else
puts "unknown answer!"
end
end
rescue Exception => e
puts e.message
end
See U

Attached