LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Closed Thread
  Search this Thread
Old 10-20-2007, 05:00 PM   #1
lisa000
LQ Newbie
 
Registered: Oct 2007
Posts: 4

Rep: Reputation: 0
About multiple timeout in Socket Programming


I am implementing a peer-to-peer program: When a computer A receives “get file XXX” from stdio, it broadcasts (floods) a request packet to ask others. Both Computer B and C have the file so they send back responses. Computer A pick up B and sends confirm to B. at the same time, it creates a server socket to listen to connection. After Compute B receives the confirm from A, it creates a client socket to connects to A.

I set timeouts to both request and confirm packets. If no response is received by A after timeout, A needs to flood a new request packet again. Otherwise, A cancels timeout of the request. For the same reason, if B does not connect to A, A will send a confirm to C so that C can connect to A

My Questions: How to set timeout?
a. I can use select(). But since I already put a select() with timeout parameter as NULL in a while loop to monitor stdio, request, confirm/response packets, it seems that there is no place to put other selects with timeout parameters。
b. I can use alarm(). But there is no way to know, which request/confirm of which file the alarm() is for. And if I cancle a timeout using alarm(0), other timeout using alarm() is also canceled.
c. I also thought about using fork()+ select(): But after the child process is terminated, how do I know it is terminated because of timeout or because response or connection is received? Besides, If it is terminated because of timout, In which part of program should I re-flood the request or re-send the confirm packet?

I want to solve the problem and need your help. Can any guru answer the question? Thanks
 
Old 10-20-2007, 05:07 PM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

Discussion continues here: http://www.linuxquestions.org/questi...mming.-593342/
 
  


Closed Thread



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set multiple timeout in Socket Programming. lisa000 Linux - Networking 1 10-20-2007 05:08 PM
About multiple timeout in Socket Programming lisa000 Linux - General 1 10-20-2007 05:07 PM
a question about multiple connections in socket programming moloza Programming 7 05-22-2006 10:31 AM
Socket timeout (c question) alaios Programming 13 09-11-2005 11:43 AM
help!!! how can i timeout a socket connect call... ? bzImage Programming 1 03-06-2002 02:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:07 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration