public inbox for
 help / color / mirror / Atom feed
From: dragon <>
To: "" <>
Subject: Failed to get interface list while using ioctl (WSAIoctl) compiled by cygwin
Date: Fri, 12 Aug 2022 20:01:37 +0800 (CST)	[thread overview]
Message-ID: <> (raw)


    Thans for your attention.

    I had a problem doing porting the network part。I want to get a list of network devices that can be implemented on Linux with an ioctl interface. A set of ioctl interfaces is also provided on Windows called WSAIoctl with cmd SIO_GET_INTERFACE_LIST。The WSAIoctl interface is also encapsulated in cygwin and placed in /usr/include/w32api/, libs place in /usr/lib/w32api/ws2_32 . 

   The code implemented by this interface can work correctly after compilation in MinGW and MSVC environments. But the error code of 10045 is returned after cygwin compiles. I have tested on different win10 hosts with different cygwin1.dll, but it still returned 10045(not supported).

Cygwin winsup/cygwin/fhandler/ also called WSAIoctl,it should workable, I don't understand why return error. 

I am new to cygwin,locating the issue was a bit difficult for me and hope to be able to get your help and response. 

   Thank you very much

The system environment and test code is as follows:

      host:  windows 10  (17134)

      cygwin version:   3.3.5

      gcc version:       11.3.0

gcc cmd:  gcc -C test.c -o test.exe -lws2_32

minGw cmd:  x86_64-w64-mingw32-gcc  test.c -o test.exe -lws2_32

test code is very simple, just like this:

#include <winsock2.h>

#include <ws2tcpip.h>

int main (int argc, char *argv[]){

    int s = SOCKET_ERROR;


    int ByteRet = 0;

    WSADATA wsa;

    int err = 0;


    if (WSAStartup (MAKEWORD(2,2), &wsa) != 0) {

        return -1;


    s = WSASocket (AF_INET, SOCK_DGRAM, IPPROTO_IP, 0, 0, 0);

    if (s == SOCKET_ERROR){

        return -1;


    err = WSAIoctl (s, SIO_GET_INTERFACE_LIST, 0 ,0 ,&IOInfo, sizeof (IOInfo), &ByteRet, 0 ,0);

   if (err != 0) {

      err = WSAGetLastError ();

       printf ("err:%d\r\n", err);

       return -err;


    return 0;


             reply	other threads:[~2022-08-12 12:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 12:01 dragon [this message]
2022-08-12 12:22 ` Marco Atzeri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).