If I read your code correctly, the situation is thus: You write data from the client to the server. The server reads until EOF. Your client never sends EOF (done by closing the client side input stream).
BTW: using available() is not a good idea. It only indicates how much data is available for reading without blocking. It's a better idea to read some large block of data. If less data is available, read will do the right thing.
See here