On 03/27/2013 01:00 PM, Oleg Kurchenko wrote:
> Hello,
> 
> it seems that communicating, described in
>  http://www.ararat.cz/synapse/doku.php/public:howto:activeconnection
> does not help.
> 
> I made a simple demo of tcp client, the code is shown below.
> 
> After I connected to server and took out the LAN cable and there is a
> red cross on the connection icon in the system tray, I can for about
> 30 seconds to send messages, and it does not get errors!
> 
> 
> Can this be fixed?
> 

No. TCP is a protocol designed to work on unreliable communication links
and will recover from errors. So a broken link is not immediately an
error on the TCP layer. There are timeouts that make that TCP will
consider a link dead after a certain delay.

The red cross on the connection icon you are seeing is on a completely
different layer of the network protocol (physical layer) and has nothing
to do with TCP. In more complex configurations you can pull out a cable
and communication will just go on over a different link without the TCP
communication ever being broken down. A nice example is wifi roaming.

So if you need to know when a network cable is pulled out, you need to
use a different method. Ping your local router (ICMP is not using TCP)
with a short timeout (mind alternate routes!) or get your network card
status using some OS dependent calls.

Ludo

------------------------------------------------------------------------------
Own the Future-Intel® Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game 
on Steam. $5K grand prize plus 10 genre and skill prizes. 
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to