Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It can run in VS2019, but when called in QT (5.14.1), "enet_host_create" cannot produce a server. #55

Open
sxdxzkq opened this issue Oct 3, 2024 · 1 comment

Comments

@sxdxzkq
Copy link

sxdxzkq commented Oct 3, 2024

It can run in VS2019, but when called in QT (5.14.1), enet_host_create cannot produce a server.
This is my code.

    if (enet_initialize() != 0) {
        printf("An error occurred while initializing ENet.\n");
    }

    ENetAddress address = { 0 };

    //address.host = ENET_HOST_ANY; /* Bind the server to the default localhost.     */
    enet_address_set_host(&address, "127.0.0.1");
    address.port = 7777; /* Bind the server to port 7777. */

#define MAX_CLIENTS 32

/* create a server */
    ENetHost* server = enet_host_create(&address, MAX_CLIENTS, 2, 0, 0);

    if (server == NULL) {
        printf("An error occurred while trying to create an ENet server host.\n");
        return 1;
    } else {
        printf("Started a server...\n");
    }

Why is sever null?
I've tried two compiler methods of MSVC2015_64bit-Debug and MinGW_32_bit-Debug.

I traced the code bind(socket, (struct sockaddr *)&sin, sizeof(struct sockaddr_in6)) and found the error code to be 10049 by WSAGetLastError().

How to fix this in QT?

@sxdxzkq
Copy link
Author

sxdxzkq commented Oct 3, 2024

I tested the release mode and found that it works, but the debug mode does not.(MSVC2015_64bit)
Do you have any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant