LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 05-24-2007, 06:30 PM   #1
arslanali
LQ Newbie
 
Registered: May 2007
Posts: 1

Rep: Reputation: 0
Angry 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
 
Old 05-25-2007, 02:27 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.2, Centos 5.8
Posts: 11,740

Rep: Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905
Unless you've got 4 NICs, I can't see the point. You're sending the same amt of data, plus 4 x the ctrl data overhead, and both sides will be switching between threads...., plus having to split the src file 4 ways, plus stitch the 4 results together...
Not a homework by any chance ???
 
Old 05-26-2007, 09:00 AM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 64
If you want to stripe NICs, I suggest you use something specifically designed to do so (e.g., FIREHOSE).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
recv() is not coming out of blocking after closing the socket. arunka Linux - Networking 2 06-30-2006 09:52 PM
recv() function of SOCKET ashucool83 Programming 1 10-08-2005 07:38 PM
multithreaded socket system JanusPaul Programming 2 08-12-2005 05:58 PM
function recv() in socket husniteja Programming 1 08-18-2004 09:06 AM
Red Hat 9 - How do I change TCP send/recv windows? oswald21 Linux - Networking 1 07-16-2003 05:21 PM


All times are GMT -5. The time now is 02:51 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration