我正在尝试创建一个使用 enet 发送一些数据的函数,但首先我想确保此处的示例在mips 系统上正常工作。
我在 Ubuntu 和 Mac 上测试了这个例子,它工作得非常好,但是当我在 mips 系统上测试它时,它总是无法创建主机,而在我测试的其他系统上创建主机时总是没有任何问题。这里有人知道会发生什么吗?有人告诉我这可能是 libenet.so 文件的问题,但由于它与 enet_initialize 函数一起使用,我认为它可能是其他问题。
如果有人想检查,这是我的代码:
#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;
}
我的输出是消息:欢迎来到 enet!:D 尝试创建 ENet 客户端主机时发生错误。