1

I am trying to implement the FTP protocol in Ruby. The problem is that when the user enters the bye command my program doesn't respond (the other commands work fine). Here is some of my code (the socket parts are omitted). Can anyone tell me what is going wrong? (I know that when bye is entered the standard windows FTP program sends "QUIT".)

user_on = true

while user_on  
  cmd = client.recv(2000)

  # THIS IS WHERE IT FREEZES
  if cmd.contains? 'QUIT'
    client.puts("221 Goodbye.")
    client.close
    user_on = false
  else
    puts("500 UNRECOGNIZED COMMAND")
    cmd = client.recv(2000)
  end

end
2
  • I think nobody can solve this problem without implementation details. But maybe you should check whether cmd really contains 'QUIT'.
    – alfa
    Mar 30, 2012 at 12:49
  • Did you flush? I'm not sure if that is needed, but worth a try. Mar 30, 2012 at 12:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.