【问题标题】:Is it possible to use write c code access rild socket in Android是否可以在 Android 中使用编写 c 代码访问 rild 套接字
【发布时间】:2011-12-19 08:09:06
【问题描述】:

喜欢标题。我这样写代码:

printf("create socket\r\n");

fd = socket_local_client(SOCKET_NAME_RIL,
ANDROID_SOCKET_NAMESPACE_RESERVED,
SOCK_STREAM);

if (fd < 0) {
perror ("opening radio  socket error");
exit(-1);
}



printf("fd = %d\r\n",fd);
int length = 12;
char datalength[5]={0};
datalength[0] = 0;
datalength[1] = 0;
datalength[2] = (length >>8) & 0xff;
datalength[3] = (length & 0xff);
int ret = send(fd, datalength, 4, 0);
if(ret != sizeof(int)) {
    perror ("Socket write error when sending length");
    close(fd);
    exit(-1);
}

我可以成功获取fd值,并成功发送数据。 但是从“logcat -b radio”中没有任何信息可以显示。 看来 rild 已经阻止了套接字连接。

有解决办法吗?谢谢

【问题讨论】:

  • 我无法解析您的问题标题。

标签: android c sockets


【解决方案1】:

rild 套接字由 Phone 应用程序“拥有”,因此只要该应用程序正在运行,您就无法连接到它。您可以尝试连接到 rild-debug 套接字。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-21
    • 2021-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-14
    • 1970-01-01
    相关资源
    最近更新 更多