LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 09-04-2009, 02:37 AM   #1
HariTEL
LQ Newbie
 
Registered: Sep 2009
Posts: 3

Rep: Reputation: 0
Socket close Issue


Hi All,

I am executing my application in two instances (S0 and S1) in FC8. Both will use different IP Address. Each instance will create 2TCP and 1UDP sockets. My application is written like, when one instance gets killed or crashes, the other instance will bring it up. So, when I killed S0, S1 has bought it(S0) up successfully. Now S0 will be running in background process.Then I killed S1, S0 has bought it(S1) up ,but with the TCP Sockets binding failed.Now, S1 will be running in background process. I want to solve this issue.Please help me.
I am using Socket Reuse options in all the Sockets.But still I get the above mentioned issue.
When I did netstat -na and checked I could able to see the TCP socket is still listening but not closed. I think because of this binding fails.
So, how to close the sockets when I kill my program?
 
Old 09-05-2009, 04:02 AM   #2
nkhambal
LQ Newbie
 
Registered: Mar 2005
Posts: 8

Rep: Reputation: 1
One way could be to use signals such as SIGKILL or SIGTERM. When a process receives one of these signals, it would terminate. You catch these signals in the process and then run a signal handler which will clean up the socket resources used by the process before going down. Of course you will have to do a lot of background work by storing the information about the process id, sockets id and other such resources used by the process in a shared or global memory where the signal handler can access it for clean up purpose.
 
  


Reply



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
Close socket error/problem C/C++ scmbg Programming 6 03-13-2009 04:33 AM
close socket + kernel module ibaniski Linux - Kernel 2 11-11-2008 02:45 PM
command to close tcp socket powah Linux - Networking 1 08-17-2007 12:22 PM
race condition in close socket?? jwstric2 Programming 3 03-18-2005 05:01 PM
Close socket/port THETEZ Linux - General 4 03-28-2004 08:05 PM

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

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