0

I have a c, c++ program. which is using TCP sockets.

when i make my interface down using ifdown. network interface goes down. but when i see the netstat there it still shows the connection state is established between client and server.

I want to close my socket immediately as interface is down. I know if i will reduce keep-alive time it may help.

But i want to know if there is any other better way to do this.

Does any signal gets generated when interface is down?

OR is there anything else which can tell my application that interface is down so that i can close my socket?

netstat -o output:-

> tcp        0      0 172.16.12.51:9999           172.16.12.51:38117     ESTABLISHED 3130/./DiaServertD  off (0.00/0/0)

> tcp        0      0 172.16.12.51:38117          172.16.12.51:9999     ESTABLISHED 3177/./sampleGxClie off (0.00/0/0)
piyush
  • 868
  • 13
  • 29
  • "*... still shows the connection state is established*" What does netstat **exactly** tell you? – alk May 15 '14 at 06:57
  • @alk edited the question with netstat o/p for both server and client. – piyush May 15 '14 at 07:28
  • It can take up to two minutes for a connection to be deemed dead... – Jonathan Leffler May 15 '14 at 07:30
  • Are you sure that the network interface is actually down? There is an old discussion on how ifdown doesn't always work as expected. http://ubuntuforums.org/showthread.php?t=900804 – Abhinav May 15 '14 at 07:30
  • 1
    Right, also ifconfig wlan0 down for example does not guarantee to keep the shut down device shut down, if another process ( wicd-demon for example ) also uses this device. It immediately will turn it on again. – icbytes May 15 '14 at 07:39
  • 1
    @Abhinav, yes it is down i can see it when i do ifconfig. – piyush May 15 '14 at 07:39

0 Answers0