when socket know the peer machin has already been down?


 
Thread Tools Search this Thread
Top Forums Programming when socket know the peer machin has already been down?
# 1  
Old 08-14-2009
when socket know the peer machin has already been down?

hi,

I have developed a very simple echo client/server application. I expect whenever i shutdown the server machine, the client peer detects the shutdown.In reality this doesn't happen and client continues to send and receive data.To my surprise, it even recv() returns with value greater than zero! I stops to recv() after a long period! ( about 5 minute later. )

Where is the problem? How can i detect the peer's shutdown?

Thanks in advance,
Behzad
# 2  
Old 08-14-2009
It couldn't be receiving data if there weren't data left in the queue to receive. How often do you check?

TCP connections by nature can take several minutes to break. It's a "best-effort" protocol which is very stubborn about waiting and retrying. I once saw a connection survive a 15-minute network outage then come back alive with a torrent of backed-up data. UDP on the other hand either goes or it doesn't.
# 3  
Old 08-15-2009
How can i tell the TCP socket to acknowledge me dropping of the connection and not to try anymore?
# 4  
Old 08-15-2009
To reiterate, TCP takes a while to detect and close broken connections because that is what it is designed to do, because it's a stream socket with best-effort delivery. If you don't want that behavior, don't use a stream socket with best-effort delivery. UDP would be more appropriate. You could also use ICMP -- that is, ping.

Last edited by Corona688; 08-15-2009 at 01:39 PM..
# 5  
Old 08-15-2009
in fact i was using TCP for a fault tolerant system(Redundant Servers). I have 2 servers.One is in standby mode and the other in active mode.Whenever the active server went down, the standby server takes the role.I wrote a small application that is run on both servers. In one it is in server mode and in another it is in client.For this scenario it seems that TCP is not well suited. By your suggestion about "best-effort" delivery mechanism i read internal details of TCP protocol and reached your experience! Thank u.
Any way, i will try ping. it may help to reach my goal.Any suggestion for my redundant servers well appreciated.

Thanks in advance
Behzad
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Add AIX machin to my windows network

Hi, Can you explain me step by step how can add my aix 6.1 to windows network. Thans:rolleyes: (5 Replies)
Discussion started by: tatab355
5 Replies

2. UNIX for Advanced & Expert Users

Fatal: Read from socket failed: Connection reset by peer [preauth]

Hello, I have recently updated my AIX machine from version 6.1.7.5 to 6.1.9.1 and i noticed that the errpt of the server is full of ssh messages like the one below: sshdprocess_id>]: fatal: Read from socket failed: Connection reset by peer Does anyone knows if this a known bug of the ssh... (15 Replies)
Discussion started by: omonoiatis9
15 Replies

3. IP Networking

Problem with Static route through peer to peer connection

Hi, I am trying to add a static route in one of 3 server (S3) so that I can access the main application server (S1). But problem is, the server (S3) where I am trying to add static route is connected with another server (S2) which is in same private network of application server (S1). I have... (9 Replies)
Discussion started by: ImranBD
9 Replies

4. IP Networking

Clarification - Setting socket options at the same time when socket is listening

I need clarification on whether it is okay to set socket options on a listening socket simultaneously when it is being used in an accept() call? Following is the scenario:- -- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies

5. UNIX for Dummies Questions & Answers

fatal: Read from socket failed: Connection reset by peer

I get this error when I log in through console: "fatal: Read from socket failed: Connection reset by peer". Can you tell me what this is and why it happens, and how to stop it? Thank you. (1 Reply)
Discussion started by: iamnew2solaris
1 Replies

6. IP Networking

Firewall stopping Peer to Peer File sharing

I am looking for advice on a router. I am new to Linux and am trying to use Limewire and Ktorent and can make no connection. Limewire indicates I have a firewall. I have a Linksys router WRK54G and my guess is that is the problem. I have spent hours upon hours trying to get it to work using info... (0 Replies)
Discussion started by: Paul K
0 Replies

7. Solaris

peer-to-peer connection on solaris and windows

hi everyone. As a solaris/unix beginner, I am trying a peer-to-peer connection with my Sun and Windows. Here is my setup: -Windows XP -Sun System (Netra T1) which is connected to the console of the WinXP machine. -Windows XP has wireless connection which enables me to access internet ... (3 Replies)
Discussion started by: graboid888
3 Replies

8. UNIX for Advanced & Expert Users

connect problem for sctp socket (ipv6 socket) - Runtime fail Invalid Arguments

Hi, I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime. To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies

9. Shell Programming and Scripting

how to get the list of process running in the server from the local machin n unix ?

how to get the list of process running in the server from the local machin n unix ? (3 Replies)
Discussion started by: guhas
3 Replies
Login or Register to Ask a Question