Thanks a lot for the reply. I have some comments though (inline).
Even though the connections are uniquely identified by both endpoints,
it might still be the problem. Since two or more sockets would share the
same local endpoint, if they all try to send data at the same time, it
is like 2 or more people trying to enter through a single window at the
same time. I am pretty sure about this, because when I introduced a
random delay before sending over the file, the file went through without
I actually did some research after posting: basically read the RFC
). Actually, they have a different
design for this problem. The server has two components: (1) A protocol
interpreter (PI), which reads a line and replies accordingly, always
waiting for new connections at the same port, and (2) Data Transfer
Process, which exclusively takes care of file transfers. This transfer
happens at different port than the one where PI listens, which is
specified by the server at runtime.
So my solution would be either of (1) making the connecting to be
processed serially (and I can afford that since my file transfers are
pretty quick), or (2) follow the design of the ftp server.