EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: How to detect AsynIPPort disconnect?
From: Mark Rivers via Tech-talk <[email protected]>
To: Dirk Zimoch <[email protected]>, Torsten Bögershausen <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Thu, 14 Feb 2019 13:14:35 +0000
Hi Dirk,


The problem you are seeing is due to the behavior of the behavior of recv() on your particular OS.  This is from the man page for recv():


***************

RETURN VALUE
       These calls return the number of bytes received, or -1 if an error occurred.  In the event of an error, errno is set to indicate the error.  The return value will be 0 when the peer  has  performed an orderly shutdown.

ERRORS
       These are some standard errors generated by the socket layer.  Additional errors may be generated and returned from the underlying protocol modules; see their manual pages.

       EAGAIN or EWOULDBLOCK
              The  socket  is marked nonblocking and the receive operation would block, or a receive timeout had been set and the timeout expired before data was received.  POSIX.1-2001 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities.

***************


For 15 minutes recv() is returning -1 with SOCKERRNO=EAGAIN, EINTR, or EWOULDBLOCK. After 15 minutes recv() finally returns 0, which according to man recv means the peer has performed an orderly shutdown.  Is this on Linux?  The last time I remember testing on Windows the time before recv() returns 0 was much shorter, 30 seconds I think.


As Torsten suggested, you can use asynSetOption to set the option DisconnectOnReadTimeout=Y.  That way any time a read operation times out it will disconnect the port.  This was added in asyn R4-29.



The following table summarizes the drvAsynIPPort driver asynSetOption keys and values.

Key     Value   Description
disconnectOnReadTimeout N Y     Default=N. If Y then if a read operation times out the driver automatically disconnect the IP port.
hostInfo        <host>:<port>[:localPort] [protocol]    The IP port hostInfo specification using the same syntax as drvAsynIPPortConfigure. This option allows changing at run time the Internet host and port to which this asyn port is connected. The only restriction is that the setting of the COM (TELNET RFC 2217) protocol cannot be changed from that specified with drvAsynIPPortConfigure. This is because if COM is specified in the drvAsynIPPortConfigure command then asynOctet and asynOption interpose interfaces are used, and asynManager does not support removing interpose interfaces.

In addition to these key/value pairs if the COM protocol is used then the drvAsynIPPort driver uses the same key/value pairs as the drvAsynSerialPort driver for specifying the serial parameters, i.e. "baud", "bits", etc.



Mark



________________________________
From: [email protected] <[email protected]> on behalf of Torsten Bögershausen via Tech-talk <[email protected]>
Sent: Thursday, February 14, 2019 5:38 AM
To: Dirk Zimoch
Cc: EPICS
Subject: Re: How to detect AsynIPPort disconnect?


> Am 14.02.2019 um 11:51 schrieb Dirk Zimoch via Tech-talk <[email protected]>:
>
> Hello,
>
> I have a network device connected with drvAsynIPPort. When I switch off the device, the asyn port stays in "connected" state for about 15 minutes.

What happens then ?
>
> Writes to the device report no error, reads time out of course. But the port is still shown as connected. I have an exceptionCallback installed, but that is not triggered.
>

Later asyn versions (including 4.34) have an option
"disconnectOnReadTimeout"

> How can I make asyn find out within a reasonable time if the device is still connected?
>

Stolen from asynRecord.c:

    case asynRecordDRTO:
        status = pasynRecPvt->pasynOption->setOption(pasynRecPvt->asynOptionPvt,
           pasynUser, "disconnectOnReadTimeout", drto_choices[pasynRec->drto]);
        break;


> Using asyn 4.34 and EPICS 7.0.1.
>
> Dirk

HTH

Replies:
Re: How to detect AsynIPPort disconnect? Dirk Zimoch via Tech-talk
References:
How to detect AsynIPPort disconnect? Dirk Zimoch via Tech-talk
Re: How to detect AsynIPPort disconnect? Torsten Bögershausen via Tech-talk

Navigate by Date:
Prev: Re: How to detect AsynIPPort disconnect? Torsten Bögershausen via Tech-talk
Next: Re: How to detect AsynIPPort disconnect? Dirk Zimoch via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: How to detect AsynIPPort disconnect? Torsten Bögershausen via Tech-talk
Next: Re: How to detect AsynIPPort disconnect? Dirk Zimoch via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
ANJ, 14 Feb 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·