Can you print the errno on bind failure? If you have a small program, just run it via strace and see the return value for bind.
I ran your same program with a few includes etc. and it worked. I built it statically on Linux (without NDK) and pushed it to an Android instance and it worked without any problems. On 15-May-2012, at 4:39 PM, [email protected] wrote: > Yes , the directory exists and I have permissions to write to it > > ------Original Message------ > From: Suman Saraf > To: [email protected] > Cc: android-porting > Subject: Re: [android-porting] Error on socket bind > Sent: May 15, 2012 4:22 PM > > Does a directory /data/local exist on the filesystem and do your program have > permissions to write to it? > > On 15-May-2012, at 4:01 PM, NimeshChanchani wrote: > >> I'm getting an error on socket bind in android . i'm not doing this >> through NDK , but cross compiling for android. I'm using AF_UNIX. code >> snippet below. Any Idea? >> >> sockfd = socket(AF_UNIX, SOCK_STREAM, 0); >> if (sockfd < 0) >> { >> printf("Error opening socket"); >> return -1; >> } >> >> bzero((char *) &server_addr, sizeof(server_addr)); >> server_addr.sun_family = AF_UNIX; >> strcpy(server_addr.sun_path, "/data/local/ipctest"); >> unlink(server_addr.sun_path); >> >> if (bind(sockfd, (struct sockaddr *) &server_addr, >> strlen(server_addr.sun_path) + sizeof(server_addr.sun_family)) < 0) >> { >> printf("Error on binding socket"); >> return -1; >> } >> >> -- >> unsubscribe: [email protected] >> website: http://groups.google.com/group/android-porting > > > > Sent from BlackBerry® on Airtel -- unsubscribe: [email protected] website: http://groups.google.com/group/android-porting
