I try to set my socket to non-blocking mode using ioctlsocket
, but it returns -1
and WSAGetLastError
returns 10045
- Operation not supported. Why could that happen?
The code I write is rather specific, because it's not C++, but Lisp with Foreign Language Interface (it allows calling C and C++ functions from dll's), but really it doesn't matter, because everything else does work.
Here is the code:
(defconstant FIONBIO #x5421)
(setf socket-descriptor (socket AF_INET SOCK_STREAM IPPROTO_TCP))
...
(fli:with-dynamic-foreign-objects ((no-block (:unsigned :long) :initial-element 1))
(ioctlsocket socket-descriptor FIONBIO no-block))
...
socket-descriptor
- is just a socket descriptor, created with standard function socket
FIONBIO
- a constant, I've found it's value just by googling it
no-block
- a pointer to u_long
, value of th u_long is 1
.
ioctlsocket
returns -1 and WSAGetLastError
returns 10045.