enet
enet copied to clipboard
It can run in VS2019, but when called in QT (5.14.1), "enet_host_create" cannot produce a server.
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?
I tested the release mode and found that it works, but the debug mode does not.(MSVC2015_64bit)
Do you have any solution?