在Android的NDK采用socket() [英] Using Socket() in Android NDK

查看:295
本文介绍了在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),错误号= 13,我有以下我的清单中定义:

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.

推荐答案

<一个href=\"http://stackoverflow.com/questions/2378607/what-permission-do-i-need-to-access-internet-from-an-android-application\">What允许我需要从Android应用程序访问互联网?

这答案这有助于我是这样的部分:
你要加入这一行:

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中应用标签

outside the application tag in your AndroidManifest.xml

这篇关于在Android的NDK采用socket()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆