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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -