Socket Binding Error-98

95 views
Skip to first unread message

Anil

unread,
Mar 30, 2009, 3:16:47 AM3/30/09
to android-porting, anil.n...@stericsson.com
Hi,
I have defiend a dameon which I have invoked from init.rc. This
daemon wait on socket.

-------------init.rc code
service myserviced system/bin/myserviced
user root
oneshot
-------------

Every time I flash the image, the first time I am able to bind to
the socket. But on restart, I get error (98- Unable to bind to socket)
when binding to the socket.


Code snippet for socket server is as below:
-----------------
if( (ListenerFd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0)
exit(0);
}

bzero(&srv, sizeof(srv));
srv.sin_family = AF_LOCAL;
srv.sin_addr.s_addr = INADDR_ANY;
srv.sin_port = htons(PORT);
if( bindStatus = bind(ListenerFd, (struct sockaddr *) &srv, sizeof
(srv)) < 0) {

LOGD("agpsserver.c: Error: bind %d\n", errno);
exit(1);
}
--------------

Thanks in advance
Anil

David Turner

unread,
Mar 30, 2009, 8:35:26 AM3/30/09
to android...@googlegroups.com, anil.n...@stericsson.com
It looks like you're trying to bind to a Unix local socket with a struct sockaddr_in descriptor. This cannot work.
You should either use an AF_INET socket, or use a struct sockaddr_un descriptor.
Reply all
Reply to author
Forward
0 new messages