android - socket(AF_INET, SOCK_DGRAM, 0) Fail return -1 -
in android m, compiled daemon , driver communication, program has use
struct sockaddr_in addr; char buffer[1024]; mcsocket_t *mcs = (mcsocket_t *)data; /* initialize socket */ mcs->sock = socket(pf_inet, sock_dgram, 0); if(mcs->sock < 0) { //loge("%s: error on socket(): %d", __func__, mcs->sock); loge("%s: error on socket(): %d = %s", __func__, errno, strerror(errno)); goto exitcommandthread; } bzero(&addr, sizeof(addr)); addr.sin_family = af_inet; addr.sin_port = htons(mcs->port); addr.sin_addr.s_addr = inaddr_any; /* bind address , port */ if (0 != bind(mcs->sock, (struct sockaddr*)&addr, sizeof(addr))) { loge("%s: error on bind(): %d = %s", __func__, errno, strerror(errno)); running = 0; }
but executed /system/bin/daemon ,socket(pf_inet, sock_dgram, 0); returns mcs->sock=-1,print:error on socket(): 13 = permission denied
Comments
Post a Comment