Menu

TCP connection and visual basic

Help
2007-07-27
2013-05-09
  • Nobody/Anonymous

    Hi to all,
    Libnodave is a fantastic DLL, is very useful library, but i have some problem to disconnect from CP343-1 IT.
    I make some line of code in visual basic, i'm able to connect to the PLC (and also read and write merker), and i try to disconnect with this code:

    daveDisconnectPLC (connessione)
    daveFree (connessione)

    daveDisconnectAdapter (interfaccia)
    daveFree (interfaccia)

    closePort (socket)
    daveFree (socket)

    but if i make this cicle: connect>disconnect for 3 time, at the fourth time i receive a message of "connection failed". I think is because the PLC accept 3 connection at the same time. So i hope that the connection that i have made stay connected without disconnect when i excecute the upper posted code.
    Someone know how to solve the problem?

    Many thanks to the forum and best regards
    Roberto Pattaro

     
    • afk

      afk - 2007-07-27

      The reason is that libnodave doesn't yet close the socket in closePort(socket). For a TCP-connection you should use the function closesocket(socket) instead, which is implemented in the wsock32.dll.

      Axel

       
    • Nobody/Anonymous

      Thank you very much Axel, with this API now is all OK! Very good solution.

      Many Thanks
      Roberto Pattaro

       

Anonymous
Anonymous

Add attachments
Cancel