Your logic in the code seems ok, but you leave some questions open:
1) What network component are you using? DelphiX network component is very outdated.

2) "ServerSocket1.Socket.ReceiveText"
- Is this a function or a saved variable after receiving data?
- When are you using this (is it somesort of onData event)? Is this the correct way to use this by possible example projects?
- Do you use it more than once? If so, are you sure the ReveiveText remains the same. Maybe it is meant to be read to a variable first.
- Is the connection ok in both ways?