在 Android NDK 中使用 Socket() [英] Using Socket() in Android NDK
本文介绍了在 Android NDK 中使用 Socket()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个关于在原生 c 程序中使用以下行的问题:
I have a question about using the following line in a native c program:
#include <sys/socket.h>
#include <errno.h>
void testSocket()
{
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
int err = errno;
}
无法创建套接字 (sockfd = -1) 并且 errno = 13.我在 Manifest 中定义了以下内容:
The socket fails to be created (sockfd = -1) and the errno = 13. I have the following defined in my Manifest:
<uses-permission android:name="android.permission.INTERNET"/>
谁能告诉我他们有什么经验/知道为什么这不起作用?我在这一点上拉空白.
Can anyone tell me any experience they have / knowledge of why this wouldn't work? I'm pulling up blanks at this point.
推荐答案
这个答案对我有帮助的部分是:你必须添加这一行:
The part of this answer which helped me was this: You have to add this line:
<uses-permission android:name="android.permission.INTERNET" />
在您的 AndroidManifest.xml 中的应用程序标记之外
这篇关于在 Android NDK 中使用 Socket()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文