problems in multithreaded send()/recv() using tcp socket
i am implementing a multithread ftp server in linux which will work like a download accelerator.
discription:
when a client connects to server ,four tcp connection sockets are established between a client and the server using four threads.it means that 4 thread are on server side ,each sending 1/4th of the file ,each thread using single send(),and four threads on client side, each reciveing 1/4th of the file,each thread using single recv(). file is broken down in four parts.using for loop, each part are sent in the chunks of 1024 bytes append with their seqeunce number using .similarly the file is recieved by four threads in for loops using recv() and are recieved data in written on single file.
Problem
the server sends the complete file correctly and exits the thread function correctly , the connections are not closed.but the client doesnot revcive all the packets and one of the thread on clients side gets stuck.
where is the problem? is it the flow control? but doesnot tcp sockets take care flow and error control???
if I add two consecutive send() commands after the one recv()in each thread of client and in these two send() i send dummy packets. and on server side i add two recv() after the one send()in each thread ........my problem is kind of solved but delayed is increased considerably and this is not good solution....i want to know what the exact problem is , the reason behind it,and its solution tooooo
|