Sponsored Content
Top Forums Programming can-not detect TCP disconnects well Post 302319463 by ogerassimov on Monday 25th of May 2009 10:00:47 AM
Old 05-25-2009
Change Protocol

Hello pjwhite,

It the remote computer simply crash or network is cut, then how to to catch that situation? As I understand that's the question?

Let me say few words about TCP/IP

1. It is reliable and stream based protocol ...

Each sending side has a buffer for example 32 kb buffer and if there is room at the buffer all "send" or "write" operations succeeds immediately without any error and without caring if the data reaches the remote end or not. Next the tcp/ip implementation starts to send the current window of the stream as a sequence of IP packets re-transmitting them until any reply from the remote side. Without any reply this side will not know what happen.


I would like to propose to you to change your protocol ( if yours ), and to introduce ability to ping the other side with a special kind of message. Most already designed protocol has ability to do such activity or they don't need it.

I've seen from your post that you have already created that.
I mean you can create a special message that requires a special reply :

1. If there is some in-activity time you can simply pass the special message, just 1, and if the reply didn't come to start re-establishing the connection.

2. 2 is like 1.but uses OOB ( Out-Of-Band Data for such "ping" message )

Actually after sending the special message if there is no reply you can try to re-connect and if that operation fails. Actually reconnecting will also "hang" if the network is down. So timeout and asynchronoust connect is also recommended.

Best Regards
O.

or try the mika's recommendation to use keep alive but please check it if it is working. And you should configure something

"A Transmission Control Protocol (TCP) keep-alive packet is an acknowledgment (ACK) with the sequence number set to one less than the current sequence number for the connection. The Transmission Control Protocol/Internet Protocol (TCP/IP) stack can automatically generate these keep-alive messages to verify that the computer at the remote end of a connection is still available."

Best Regards
O.
 

10 More Discussions You Might Find Interesting

1. AIX

aix telnet disconnects

We're having problems getting disconnected from AIX with our telnet sessions. I can't ping the server when this happens, either. Other serves can be pinged at the same time. This happens both at unix and within the database. Database locks remain when editing files. unix logins remain after... (0 Replies)
Discussion started by: e1lyons
0 Replies

2. AIX

Telnet disconnects on handheld device AIX

I have intermec handheld device which is connecting to AIX Server on port 12431 or whatever. ( oracle application ) The handheld device connects for few seconds and then disconnects from the AIX server. Once it disconnects the handheld device automatically switches off. Are there any... (2 Replies)
Discussion started by: filosophizer
2 Replies

3. Windows & DOS: Issues & Discussions

Putty disconnects after sometime

i am using Putty to do ssh to all the unix nodes that we have in our work environment. it is very strange that all my network connections will timeout quickly in 10 mins, it can either be a putty connection, sqlplus or toad. is there some setting that can help to prevent this. please let me know... (3 Replies)
Discussion started by: sudhiroracle
3 Replies

4. Programming

How detect TCP/IP socket shutdown when ethernet cable is disconnected

Hi, I want to code TCP/IP client/server in linux application capable to fastly detect ethernet cable disconnection in any condition. So I have activate SO_KEEPALIVE options and set TCP_KEEPCNT, TCP_KEEPIDLE and TCP_KEEPINTVL to 1. When I disconnect ethernet cable I have the following... (5 Replies)
Discussion started by: jeje_clb
5 Replies

5. Programming

Socket endpoints disconnects

Hello, I am able to establish a connection, and transfer data. Occasionally the receiving client will block in read(2) and stay that way until it is killed. initial: server: netstat -aveeopT tcp 0 0 *:17398 *:* LISTEN server-user... (8 Replies)
Discussion started by: eoa
8 Replies

6. Programming

[C++] [Unix] TCP non-blocking. Detect server disconnection procedure over, from client.

Hello! I searched forum for similar topic, with no luck, if you know one, delete this topic, and send me private message with link please. Little background: I have a lot of clients and one serwer. Client can make multiple connections on different ports and ips, but only one can be acctive... (2 Replies)
Discussion started by: ikeban
2 Replies

7. Red Hat

Network disconnects often

Hi , My redhat 5 frequently disconnects from network. Once rebooted , network is working for one day or two. After that the NIC suddently stops working. Even if i give "#service network restart" or ifup eth0 commands it won't come up. I even tried reconfigure the network card. but no use. Only... (6 Replies)
Discussion started by: dknattukal
6 Replies

8. Solaris

Too much TCP retransmitted and TCP duplicate on server Oracle Solaris 10

I have problem with oracle solaris 10 running on oracle sparc T4-2 server. Os information: 5.10 Generic_150400-03 sun4v sparc sun4v Output from tcpstat.d script TCP bytes: out outRetrans in inDup inUnorder 6833763 7300 98884 0... (2 Replies)
Discussion started by: insatiable1610
2 Replies

9. UNIX for Dummies Questions & Answers

Persistent terminal windows across viewer disconnects

Is there a way to have persistent terminal windows to redhat server across viewer disconnects? I can do that with the help of an extra MS Windows server and rdp, but is there a way of doing that without the Windows server? Here's the scenario. I have multiple redhat servers (VMs) which have no... (3 Replies)
Discussion started by: ad101
3 Replies

10. SCO

Telnet session disconnects abruptly

I have inherited and SCO OpenServer Release 6 server. The clients connect using telnet to get to a proprietary database application for Service tickets. The issue I am currently having is that the connection just stops abruptly and you can see "telnet session terminated" on the terminal emulation... (22 Replies)
Discussion started by: sean6605
22 Replies
tcp.h(3HEAD)                                                          Headers                                                         tcp.h(3HEAD)

NAME
tcp.h, tcp - definitions for the Internet Transmission Control Protocol (TCP) SYNOPSIS
#include <netinet/tcp.h> DESCRIPTION
The <netinet/tcp.h> header defines the following macro for use as a socket option at the IPPROTO_TCP level: TCP_NODELAY Avoid coalescing of small segments. The macro is defined in the header. The implementation need not allow the value of the option to be set with setsockopt() or retrieved with getsockopt(). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
getsockopt(3XNET), socket.h(3HEAD), attributes(5), standards(5) SunOS 5.10 10 Sep 2004 tcp.h(3HEAD)
All times are GMT -4. The time now is 04:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy