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  <20142015  2016  2017  2018  2019  2020  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  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Possible to close a TCP/IP socket in asyn?
From: Adam Bark <[email protected]>
To: Mark Rivers <[email protected]>, Eric Norum <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Fri, 24 Oct 2014 11:29:14 +0100
Thanks Mark,

I finally figured out that I needed two different asynUsers, one to connect/disconnect the IP socket, created by asynCommonSyncIO and one to read data, created by asynOctetSyncIO. In the hope that this might help someone else out here's is a reasonably minimal example program that I was testing out ideas in.

#include <stdio.h>
#include <asynOctetSyncIO.h>
#include <asynCommonSyncIO.h>
#include <drvAsynIPPort.h>


int main()
{
    asynUser *commonDataport, *octetDataport;
    char data[8000000];
    size_t nread;
    int eomReason, i;
    drvAsynIPPortConfigure("dataport", "acq1001_040:4210", 0, 0, 0);
    printf("Connect %d\n", pasynCommonSyncIO->connect("dataport", 0,
&commonDataport, NULL));
    printf("Connect octet %d\n", pasynOctetSyncIO->connect(
               "dataport", -1, &octetDataport, NULL));
    for (i=0; i<20; i++) {
        pasynOctetSyncIO->read(octetDataport, data, 8000000, 5.0,
                               &nread, &eomReason);
        printf("read %d bytes\n", nread);
    }
    pasynManager->autoConnect(commonDataport, 0);
    printf("Disconnect %d\n", pasynCommonSyncIO->disconnectDevice(
               commonDataport));
    printf("Error: %s\n", commonDataport->errorMessage);
    sleep(20);
    pasynManager->autoConnect(commonDataport, 1);
    pasynCommonSyncIO->connect("dataport", -1, &commonDataport, NULL);
    while (1) {
        pasynOctetSyncIO->read(octetDataport, data, 8000000, 5.0,
                               &nread, &eomReason);
        printf("read %d bytes\n", nread);
    }
    return 0;
}

This requires asyn and epics base and extensions header files and the asyn library to build against. I also had to add the path of the directory containing libasyn.so to my LD_LIBRARY_PATH.

Adam.

On 23/10/14 18:55, Mark Rivers wrote:
Hi Adam,

What sequence of calls did you make?

You must do the following:

    asynUser *pasynUser;

    status =  pasynCommonSyncIO->connect(port, addr, &pasynUser, drvInfo);
...

   status = pasynCommonSyncIO->disconnectDevice(pasynUser);


It sounds like perhaps you did not call pasynCommonSyncIO->connect first?  Note that you CANNOT use a pasynUser that has been created and connected with any other method except pasynCommonSyncIO->connect().

Mark


________________________________
From: [email protected] [[email protected]] on behalf of Adam Bark [[email protected]]
Sent: Thursday, October 23, 2014 10:46 AM
To: Eric Norum
Cc: [email protected]
Subject: Re: Possible to close a TCP/IP socket in asyn?

I probably should have checked the return value from asynCommonSyncIO::disconnectDevice before, I'm getting an asynError and the asynUser::errorMessage is "asynManager::queueRequest no processCallback"

On 23/10/14 16:32, Adam Bark wrote:
I didn't but disabling doesn't appear to make a difference, the local port number doesn't change so it is not reconnecting anyway.

On 23/10/14 15:25, Eric Norum wrote:
Do you have autoconnect disabled?

On Oct 23, 2014, at 5:29 AM, Adam Bark <[email protected]<mailto:[email protected]>> wrote:

...
Thanks Mark, that certainly clarifies the situation however if I use asynCommonSyncIO::disconnectDevice (the documentation says this calls asynCommon::disconnect) the socket still shows up as "ESTABLISHED" in netstat, at least with 4-22. Am I missing some incantation? I am unclear what should go in drvPvt if I am to use asynCommon::disconnect directly.

Thanks,
Adam.
--
Eric Norum
[email protected]<mailto:[email protected]>









--

This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom







--

This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom




--
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom





References:
Possible to close a TCP/IP socket in asyn? Adam Bark
RE: Possible to close a TCP/IP socket in asyn? Mark Rivers
Re: Possible to close a TCP/IP socket in asyn? Adam Bark
Re: Possible to close a TCP/IP socket in asyn? Eric Norum
Re: Possible to close a TCP/IP socket in asyn? Adam Bark
Re: Possible to close a TCP/IP socket in asyn? Adam Bark
RE: Possible to close a TCP/IP socket in asyn? Mark Rivers

Navigate by Date:
Prev: Re: compile on Windows XP with MinGW Jani Hakala
Next: Re: Focus deadlock Specht, Eliot D.
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Possible to close a TCP/IP socket in asyn? Mark Rivers
Next: Focus deadlock Specht, Eliot D.
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 17 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·