LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-07-2009, 06:04 AM   #1
raikme
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Rep: Reputation: 0
Detecting peer died in multi thread environment


Newbie to this site..

I have a process with multiple threads inside. In one of the threads(A), there is a TCP socket
connection towards a server. Data is being sent from the thread A towards this server. At one point of
time, server is down abruptly, which is detected by the thread A only after 15 minutes.
During this 15 minutes, the data sent by thread A, using unix command "send" are successful.

My queries

1. why, the "send" command doesn't fail immediately? Why it takes 15 minutes for this detection?
2. I tried to catch the signal SIGPIPE in thread A itself using signal function, but it doesn't work, which means "send"
command still is successfull?
3. Should the signals be catched at thread level or process level?

Could you please clarify.

Thanks!
 
Old 12-07-2009, 08:46 AM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Your connection might have been buffering in which case you might want to set TCP_NODELAY on the socket, this is typically used in situations where each individual send is small but you want it sent right away instead of getting buffered before sending.
 
Old 12-08-2009, 10:14 PM   #3
raikme
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks for the info.

Does it still work, even if the Peer host itself crashes or unreachable? Assume, its not the case of Peer process crashing.
Because, in case TCP is actively sending data, in case of Peer host itself crashes or unreachable, TCP will time out(may be after 15 minutes), and socket's pending error is set to ETIMEDOUT.
Will this case, also be solved by using TCP_NODELAY?
Could you please clarify. Thanks!
 
Old 12-08-2009, 10:24 PM   #4
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Quote:
Originally Posted by raikme View Post

At one point of time, server is down abruptly, which is detected by the thread A only after 15 minutes.

My queries

1. why, the "send" command doesn't fail immediately? Why it takes 15 minutes for this detection?
May be because server is down, but link still active?
 
Old 12-08-2009, 11:04 PM   #5
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
raikme - yes if the peer has crashed you won't know it until bytes are actively sent so either when the keepalive timer kicks one out or your send fills its buffer and sends it out. The TCP_NODELAY tells send not to buffer but send out the data immediately, this should eliminate the delay of getting a SIGPIPE when the connection is down.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Loadbalancer: telnetd: ttloop: peer died: EOF Muddoll Linux - Enterprise 0 11-18-2008 04:10 AM
You are subscribed to this thread Connection reset by peer (S: vsftpd, C: gftp) baosheng Linux - Networking 1 05-13-2006 10:18 AM
Using a multi-boot box in a simple peer-to-peer network Woodsman Slackware 5 11-22-2005 08:35 PM
multi-thread VS multi-process ltcstyle Programming 3 12-04-2004 06:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

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