Two common problems with client-server programming are
- using readline (<$socket>) to read data, but not writing newlines on the other end
- not having made sure data is actually being sent (without buffering), by either calling IO::Handle's ->autoflush() (once) or ->flush() (after every write operation) on the respective handle
A cursory scan of your code seems to suggest that at least one of those problems is involved.