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 08-10-2013, 10:13 PM   #1
parthelion
LQ Newbie
 
Registered: Jul 2013
Posts: 3

Rep: Reputation: Disabled
Socket does not work after path change


Hi everyone,

I have a simple socket application running on a couple machines, pumping messages back and forth to each other. The problem I'm having is that the connection between these two machines is routed via one of two OTHER machines, and has to be tolerant of the route changing. I.E. the topology is:

Code:
Machine 1
 |  |
r1  r2
 |  | 
Machine 2
By default, the connection between machines 1 and 2 is routed through r1, but if r1 fails, scripts on Machine 1 and Machine 2 change their routes to use r2. Right now, when this happens, my socket application becomes unable to send/receive from the other end until I shutdown and reconnect the socket. I'm currently using a simple heartbeat to detect when communications have been lost, and then have each application shutdown and attempt to reconnect. It seems to work reasonably well, but someone told me that I shouldn't even have to do this and that a socket should be tolerant of this situation on its own. I note that if I have an open SSH session between the two machines, it works fine after the route change. I'd always assumed that SSH itself used a similar application-level mechanism to remake the sockets after a problem.

So my question is: is there a socket option or the like I should be using to make everything easier on myself, negating the need for the heartbeat and disconnect/reconnect? I'm obviously pretty new at this. Thanks for the help, everyone.
 
Old 08-14-2013, 03:44 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,886

Rep: Reputation: 162Reputation: 162
You can use connectionless socket, such as UDP, to exchange message. It shouldn't care of route change.
 
Old 08-17-2013, 11:42 PM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,798

Rep: Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088
Quote:
Originally Posted by parthelion View Post
someone told me that I shouldn't even have to do this and that a socket should be tolerant of this situation on its own.
Yes, I believe that it ought to work like that; you have no control over the route and should not be affected by it. The only thing I can think of is maybe you need longer timeouts?

Quote:
Originally Posted by nini09
You can use connectionless socket, such as UDP, to exchange message. It shouldn't care of route change.
Actually, UDP will probably lose some packets when the route changes, whereas TCP will resend lost packets so it's more tolerant of route changes.
 
  


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
[SOLVED] why local socket does not work if the socket file exist before? golden_boy615 Programming 4 12-14-2011 09:26 AM
System_daemon:how to change mysql socket path? nadirkm Linux - Software 1 02-25-2010 09:29 AM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 02:05 PM

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

All times are GMT -5. The time now is 01:39 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