Open jimklimov opened 2 years ago
The sktconnect()
, sktclose()
, sktread()
, sktwrite()
defined in wincompat.h
seem to abstract this platform nuance to behave as expected with same code (and data types) as for POSIX code. At least, porting a variant of those methods to nutclient.cpp
to address #1598 helped make the C++ client library functional (passes NIT).
Conversely, check apcupsd-ups.c
(and struct pollfd->fd
involved) whether they needed changes for TYPE_FD_SOCK
or can do without? At least, that code also uses wincompat.h
and so should have the tweaked socket()
implementation, it seems.
UPDATE: Or maybe not - not without #define W32_NETWORK_CALL_OVERRIDE
in play. This may be a point of interest for upsd.c
however - it has the overrides and yet its build failures prompted introduction of TYPE_FD_SOCK
in the first place. And "as is" at the moment, it works well enough to pass integration tests...
According to https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-ioctlsocket, https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect, https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-closesocket etc. type of
sock_fd
gotta beSOCKET
in WIN32 builds, soTYPE_FD_SOCK
(and related macros) for us., usingclosesocket()
instead ofclose()
, etc.However
clients/upsclient.c
apparently gets away withint
(and doesn't includewinsock*.h
either, at least not explicitly -common.h
pulls that into most of our sources, though). Maybe ourwincompat.h
does wonders, or the code is broken.NOTE: This is about
UPSCONN_t
defined inclients/upsclient.h
, which is different fromserver/upstype.h
definedupstype_t
which does useTYPE_FD
already.