It is better if you can provide the code in question otherwise it's difficult to know what is going on. Please provide. Need to know what the "result" variable is after you call recvln. Also need to know what you have set timeout to be.
If you provide more detail on what you are trying to achieve overall I can suggest an approach e.g.
what are you sending, what gets sent back in response, what decisions do you need to make with respect to what is received, Does the command itself get echoed back etc. etc.