Hey guys !
i want to create a server that close when client send END_CALL
so i writed this code
Server.rb
require "socket"
s = TCPServer.new("127.0.0.1",2000)
msg = ""
client = s.accept()
while msg = client.gets
puts msg
if msg.equal?("END") == true
break
end
end
client.close()
s.close()
Client.rb
require "socket"
s = TCPServer.new("127.0.0.1",2000)
msg = ""
client = s.accept()
while msg = client.gets
puts msg
if msg.equal?("END") == true
break
end
end
client.close()
s.close()
but when i type END_CALL in the client nothing happen
pliz help and thanks
Hey guys !
i want to create a server that close when client send END_CALL
so i writed this code
Server.rb
require "socket"
s = TCPServer.new("127.0.0.1",2000)
msg = ""
client = s.accept()
while msg = client.gets
puts msg
if msg.equal?("END") == true
break
end
end
client.close()
s.close()
Client.rb
require "socket"
s = TCPServer.new("127.0.0.1",2000)
msg = ""
client = s.accept()
while msg = client.gets
puts msg
if msg.equal?("END") == true
break
end
end
client.close()
s.close()
but when i type END_CALL in the client nothing happen
pliz help and thanks
It looks like you pasted the server code twice.
One problem is that you are testing for the string "END", but in reality the string is probably something else (hard to say what).
To find out, use
p msg
instead of
puts msg
and you will see if there is (for example) a newline in the string: "END\n", or if it is "END_CALL\n" or something else.