I'm creating a modbus slave using the libmodbus.dll in python on Windows OS. I've used ctypes to load the dll and make use of its features. There is a sample code I'm mimicking here. One of the call's in the dll ends up opening a socket
s = modbus_tcp_listen(ctx, 1);
At the end of the example it has a line where it close's the socket like so
close(s);
close()
is not part of the libmodbus.dll. It's from the library #include <unistd.h>
. Is there a way to close the socket without having to obtain a dll with the close()
functionality? If not, how would I obtain access to the close()
command on a windows platform? From what I know unistd.h
is for posix.
You can use the
socket.close(fd)
which takes the socket descriptor and closed it.