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:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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
Thank you very much Axel, with this API now is all OK! Very good solution.
Many Thanks
Roberto Pattaro