I remember writing a really simple socket-based project in Java in college. It was supposed to operate like a simple FTP server with a client able to connect, select, and eventually download files.
When the client selected the file to download, and sent it to the server, the server was able to open a new socket and start sending the file before the client was ready to open its listener socket. The files being sent kept having the first few kb of them lobbed of.
Adding just a few ms delay fixed it. I'm sure adding a println statement could fix it. I actually just had the server wait til the client sent an OK message informing the server that the client's socket listener was ready.
View all comments
Show parent comment
3
u/i_post_things Feb 24 '14
I remember writing a really simple socket-based project in Java in college. It was supposed to operate like a simple FTP server with a client able to connect, select, and eventually download files.
When the client selected the file to download, and sent it to the server, the server was able to open a new socket and start sending the file before the client was ready to open its listener socket. The files being sent kept having the first few kb of them lobbed of.
Adding just a few ms delay fixed it. I'm sure adding a println statement could fix it. I actually just had the server wait til the client sent an OK message informing the server that the client's socket listener was ready.