Networking Forums

Networking Forums > Computer Networking > Linux Networking > Problem with sockets

Reply
Thread Tools Display Modes

Problem with sockets

 
 
Andrea Sini
Guest
Posts: n/a

 
      02-02-2005, 09:39 PM
Hello,

I'd like to know if there is a way to know if one of the sides of a TCP
connection is down without sending any message, using some API (in UNIX)

Thanks

Andrea
 
Reply With Quote
 
 
 
 
Pat_Tongco@spamcdo.org
Guest
Posts: n/a

 
      02-03-2005, 07:32 PM
On 2005-02-02, Andrea Sini <(E-Mail Removed)> wrote:
> Hello,
>
> I'd like to know if there is a way to know if one of the sides of a TCP
> connection is down without sending any message, using some API (in UNIX)
>
> Thanks
>
> Andrea


Simply evaluating the value returned by
both sides' connect() call?


--
- Pat Tongco
2.6.10-ck5.012105
 
Reply With Quote
 
jimxu
Guest
Posts: n/a

 
      02-04-2005, 01:36 AM

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 2005-02-02, Andrea Sini <(E-Mail Removed)> wrote:
> > Hello,
> >
> > I'd like to know if there is a way to know if one of the sides of a TCP
> > connection is down without sending any message, using some API (in UNIX)
> >
> > Thanks
> >
> > Andrea

>
> Simply evaluating the value returned by
> both sides' connect() call?
>
>
> --
> - Pat Tongco
> 2.6.10-ck5.012105


If the connection is closed normally by the remote PC, you can receive a
message with NULL data.
If the connection is down for some link layer reason, (the network is down,
etc.), the OS can not detect it, I think
you can send keepalive message to detect it.
The connect() function can be used to setup a TCP/UDP connection, if you
want use this funtion to test a connected socket,
it is not so good. BTW, you can only get the return value asynchronous.

--
jimxu
*NO PAINS, NO GAINS*


 
Reply With Quote
 
Phil Frisbie, Jr.
Guest
Posts: n/a

 
      02-04-2005, 05:36 PM
Andrea Sini wrote:

> Hello,
>
> I'd like to know if there is a way to know if one of the sides of a TCP
> connection is down without sending any message, using some API (in UNIX)


No, but if one end closed gracefully then the other end will get a '0' return
from recv() to signal end of stream.

> Thanks
>
> Andrea


--
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com

 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      02-04-2005, 05:58 PM

"Andrea Sini" <(E-Mail Removed)> wrote in message
news:_EcMd.488285$(E-Mail Removed)...

> I'd like to know if there is a way to know if one of the sides of a TCP
> connection is down without sending any message, using some API (in UNIX)


A moment's reflection should tell you that this is impossible in
principle. If the host disappears, how could you tell except by sending it a
message and noticing either its failure to respond or a resulting error?

DS


 
Reply With Quote
 
steve_schefter@hotmail.com
Guest
Posts: n/a

 
      02-04-2005, 07:13 PM
Hi Andrea.

> I'd like to know if there is a way to know if one of the sides of a

TCP
> connection is down without sending any message, using some API (in

UNIX)

It depends what you mean by "without sending any message". If you mean
from the application (so that you don't have to have a new message that
the remote will understand), then turn on TCP keepalives. A message is
sent, but it is sent by the stack and hidden from the apps.

For more details, search for "+so_keepalive +schefter" in google
groups.

Regards,
Steve

------------------------------------------------------------------------
Steve Schefter phone: +1 705 725 9999 x26
The Software Group Limited fax: +1 705 725 9666
642 Welham Road,
Barrie, Ontario CANADA L4N 9A1 Web: www.wanware.com

 
Reply With Quote
 
Phil Frisbie, Jr.
Guest
Posts: n/a

 
      02-04-2005, 11:14 PM
(E-Mail Removed) wrote:

> Hi Andrea.
>
>>I'd like to know if there is a way to know if one of the sides of a

> TCP
>>connection is down without sending any message, using some API (in

> UNIX)
>
> It depends what you mean by "without sending any message". If you mean
> from the application (so that you don't have to have a new message that
> the remote will understand), then turn on TCP keepalives. A message is
> sent, but it is sent by the stack and hidden from the apps.
>
> For more details, search for "+so_keepalive +schefter" in google
> groups.


However, note that TCP keepalives are depreciated, and by default they have a
time-out of 2 hours! Yes, you can change the time-out to something shorter, down
to seconds if you wish, but on most OSs this is a global setting, so it will
effect ALL TCP connections.


--
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem using sendto(...) with packet sockets? jan.chludzinski@gmail.com Linux Networking 0 05-14-2008 03:13 PM
Problem - Home network using house phone sockets. David Jones Home Networking 9 08-06-2004 10:20 PM
sockets Sam Linux Networking 2 07-07-2004 08:54 AM
Problem while creating two different sockets. Rajat Linux Networking 0 05-19-2004 12:38 PM
sockets =?ISO-8859-1?Q?Andreas_R=F8sdal?= Linux Networking 5 02-03-2004 02:48 PM



1 2 3 4 5 6 7 8 9 10 11