简体   繁体   English

Enet.c 库在 mips 系统上无法正常工作

[英]Enet.c library not working correctly on mips system

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.我正在尝试创建一个使用 enet 发送一些数据的 function,但首先我想确保此处的示例在 mips 系统上正常工作。

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.我在 Ubuntu 和 Mac 上测试了这个例子,它工作得非常好,但是当我在 mips 系统上测试它时,它总是无法创建主机,在我测试的其他系统上总是创建没有任何问题。 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.有人告诉我这可能是 libenet.so 文件的问题,但由于它适用于 enet_initialize function,我认为它可能是其他问题。

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.而我的 output 是消息:Welcome to enet: .D An error occurred while trying to create an ENet client host。

Try debugging it and stepping into the enet_host_create function to see where it's failing.尝试调试它并进入enet_host_create function 以查看它失败的地方。 It looks like the source code for that function is in the header file .看起来 function 的源代码在header 文件中。

If you're not able to debug and step through it, you could temporarily modify the header file to add additional logging.如果您无法调试和单步执行,您可以临时修改 header 文件以添加额外的日志记录。

Some potential reasons it's failing:它失败的一些潜在原因:

  • peerCount > ENET_PROTOCOL_MAXIMUM_PEER_ID
  • enet_malloc malloc fails to allocate memory enet_malloc malloc 分配 memory 失败
  • net_socket_create(ENET_SOCKET_TYPE_DATAGRAM) == ENET_SOCKET_NULL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM