I'm trying to create a function which uses enet to send some data, but first I wanted to make sure the example in here works correctly on the mips system.
I tested the example on Ubuntu and Mac and it works perfectly fine, but when I test it on the mips system it always fails to create the host, which is always created without any trouble on the other systems I tested. Do someone here knows what might be happening? Someone told me that it might be a problem with the libenet.so file, but since it works with the enet_initialize function, I think it might be something else.
This is my code if someone wants to check it out:
#define ENET_IMPLEMENTATION
#include <enet.h>
#include <stdio.h>
int main() {
if (enet_initialize () != 0) {
printf("An error occurred while initializing ENet.\n");
return 1;
}
else {
printf("Welcome to enet! :D\n");
}
//Client side
ENetHost* client = { 0 };
client = enet_host_create(NULL /* create a client host */,
1 /* only allow 1 outgoing connection */,
2 /* allow up 2 channels to be used, 0 and 1 */,
0 /* assume any amount of incoming bandwidth */,
0 /* assume any amount of outgoing bandwidth */);
if (client == NULL) {
fprintf(stderr,
"An error occurred while trying to create an ENet client host.\n");
exit(EXIT_FAILURE);
}
else {
printf("Client created successfully! :D\n");
}
enet_host_destroy(server);
enet_deinitialize();
return 0;
}
And my output is the messages: Welcome to enet! :D An error occurred while trying to create an ENet client host.
Try debugging it and stepping into the
enet_host_createfunction to see where it's failing. It looks like the source code for that function is in the header file.If you're not able to debug and step through it, you could temporarily modify the header file to add additional logging.
Some potential reasons it's failing:
peerCount > ENET_PROTOCOL_MAXIMUM_PEER_IDenet_mallocmalloc fails to allocate memorynet_socket_create(ENET_SOCKET_TYPE_DATAGRAM) == ENET_SOCKET_NULLI'm thinking that it's probably not an issue with the
peerCountbecause the defaultENET_PROTOCOL_MAXIMUM_PEER_IDis0xFFFand you're passing1.It may be an issue with
enet_mallocornet_socket_create. By defaultenet_mallocis just the regularmallocfrom stdlib, which I'm guessing is what you're using since you're not initializing withenet_initialize_with_callbacks. Andenet_socket_createjust calls thesocketsystem call:I would make sure your platform's
mallocandsocketimplementations are working as expected.