Menu

Keep tcp connection while disconnect cable

Help
2007-04-20
2013-05-09
  • Nobody/Anonymous

    Luca_TGMX (luca_tgmx@jabber.org)

    I have a problem using ethernet connection with a plc:

    My software is working great but if I disconnect and reconnect ethernet cable, program crash.

    How can I resolve this problem?

    The code is something like this:

        fds.rfd=openSocket(102, ip.ascii());
        fds.wfd=fds.rfd;
        di =daveNewInterface(fds,"IF1",0, daveProtoISOTCP, daveSpeed187k);
        res =daveInitAdapter(di);
        dc =daveNewConnection(di, 0, 0, 2);
        res =daveConnectPLC(dc);

        while(1)
        {
        if(daveReadBytes(dc, daveDB, NUM_DB, DE_FINE_DEPOSITO, 2, NULL)==0)
                {
                b=daveGetU8(dc);   
                c=daveGetU8(dc);
                }
        if(b==0 && c==0)
            break;
        usleep(100000);   
        }

    THANKS.

     
    • Nobody/Anonymous

      Il problema riguarda la libreria LIBNODAVE...
      dovresti fare un debug in c++

       
      • Nobody/Anonymous

        I have the same problem. I tried everything but I couldn't solve it

         
        • afk

          afk - 2007-12-02

          The TCP-connection can't be kept when the cable is disconnected, but with the return-code of daveReadBytes you can detect that there is a failure, and you can try to reconnect until the connection is up again.

          Axel

           
    • Nobody/Anonymous

      Luca_TGMX (luca_tgmx@jabber.org)

      I've done this but during reconnection I also must call "close(fds.rfd)" to free the socket because it's not enought to call:

      daveDisconnectPLC(dc);
      daveDisconnectAdapter(di);

      Can u tell me why?

       

Anonymous
Anonymous

Add attachments
Cancel