Server-Socket get's connected - application crashes immediatly

312 views
Skip to first unread message

Stefan Krecher

unread,
Mar 19, 2010, 12:29:37 PM3/19/10
to android-ndk
Hi,
still porting Squeak to android (http://code.google.com/p/squeak-
android-vm/) - i encounter problems with server-sockets.
Server-Sockets (listening on ports > 1024) seem to crash the
application immediatly when a connection get's established.
The Socket-Part is a straighforward unix-socket implementation in
plain "C".
Added android.permission.INTERNET - do i need more permissions to
setup server-sockets?
Or is it disallowed to use server-sockets with the ndk?
Regards,
Stefan

David Turner

unread,
Mar 19, 2010, 12:59:57 PM3/19/10
to andro...@googlegroups.com
On Fri, Mar 19, 2010 at 9:29 AM, Stefan Krecher <stefan....@googlemail.com> wrote:
Hi,
still porting Squeak to android (http://code.google.com/p/squeak-
android-vm/
) - i encounter problems with server-sockets.
Server-Sockets (listening on ports > 1024) seem to crash the
application immediatly when a connection get's established.

"crashing the application" is certainly not acceptable behaviour. If you don't have the INTERNET
permission, stuff like bind() or connect() should return -1 with errno set to EPERM or something.

Does your application check for error codes ? If so, what are they ?
 
The Socket-Part is a straighforward unix-socket implementation in
plain "C".
Added android.permission.INTERNET - do i need more permissions to
setup server-sockets?
Or is it disallowed to use server-sockets with the ndk?

Absolutely not, as long as you have the INTERNET permission, you will be able to connect/bind to UDP/TCP sockets.
You can bind/connect to Unix-domain sockets without this permission (with the usual uid/gid restrictions on the file
being used for the socket).
 
Regards,
Stefan

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Tristan Miller

unread,
Mar 19, 2010, 1:07:15 PM3/19/10
to andro...@googlegroups.com

Do you know if you're actually getting a valid server socket?  Last time that I checked, Linux doesn't let non-root open server sockets on ports under (or equal to?) 1024.

Tristan Miller

On Mar 19, 2010 12:59 PM, "David Turner" <di...@android.com> wrote:



On Fri, Mar 19, 2010 at 9:29 AM, Stefan Krecher <stefan....@googlemail.com> wrote:
>
> Hi,

> sti...

"crashing the application" is certainly not acceptable behaviour. If you don't have the INTERNET
permission, stuff like bind() or connect() should return -1 with errno set to EPERM or something.

Does your application check for error codes ? If so, what are they ?


 
>
> The Socket-Part is a straighforward unix-socket implementation in
> plain "C".

> Added androi...

Absolutely not, as long as you have the INTERNET permission, you will be able to connect/bind to UDP/TCP sockets.
You can bind/connect to Unix-domain sockets without this permission (with the usual uid/gid restrictions on the file
being used for the socket).


 
>
> Regards,
> Stefan
>
> --
> You received this message because you are subscribed to the Google...


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.

...

Stefan Krecher

unread,
Mar 25, 2010, 11:50:33 AM3/25/10
to android-ndk
Hi,

On 19 Mrz., 18:07, Tristan Miller <trisman...@gmail.com> wrote:
> Do you know if you're actually getting a valid server socket?  Last time
> that I checked, Linux doesn't let non-root open server sockets on ports
> under (or equal to?) 1024.

i did some further investigations: the server-socket is valid, and the
listen()-call returns with no error.
The application uses i/o multiplexing via fd_set / select() etc, but
the accept-handler is never called.
Are there any known issues regarding i/o multiplexing on android? This
mechanism works fine on other Linux-derivates.

regards,
Stefan

David Turner

unread,
Mar 25, 2010, 1:19:51 PM3/25/10
to andro...@googlegroups.com
No issues that I know how. There are several uses of select() and epoll() within the system, so I doubt that's the issue here.
Can you give a little more details about what you're doing ?


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.

Stefan Krecher

unread,
Mar 25, 2010, 8:14:25 PM3/25/10
to android-ndk
Hi,

On 25 Mrz., 18:19, David Turner <di...@android.com> wrote:
> No issues that I know how. There are several uses of select() and epoll()
> within the system, so I doubt that's the issue here.
> Can you give a little more details about what you're doing ?

it's the socket-implementation for the smalltalk/ squeak-vm - i did
not code that stuff, just try to understand it and to port it to
android ...
After studying the code, i had another idea: could it be a problem
with SIGIO? I'm not sure if i understood the signalling right: a
socket in listening-state/ waiting for connections, sends SIGIO, when
a client tries to connect.
Here's a piece of code:
/* enable non-blocking asynchronous i/o and delivery of SIGIO to the
active process */
[...]
arg= getpid(); if (ioctl(fd, SIOCSPGRP, &arg) < 0)
perror("ioctl(SIOCSPGRP, getpid())");
arg= 1; if (ioctl(fd, FIOASYNC, &arg) < 0)
perror("ioctl(FIOASYNC, 1)");

David Turner

unread,
Mar 25, 2010, 9:57:33 PM3/25/10
to andro...@googlegroups.com
According to Wikipedia, SIGIO == SIGPOLL and does only work with poll()


It may be a kernel configuration issue. But very frankly, there must be a better way to do that than a signal.


--

Stefan Krecher

unread,
Mar 26, 2010, 6:22:10 AM3/26/10
to android-ndk
On Mar 26, 2:57 am, David Turner <di...@android.com> wrote:
> According to Wikipedia, SIGIO == SIGPOLL and does only work with poll()
>
> http://en.wikipedia.org/wiki/SIGIO
>
> <http://en.wikipedia.org/wiki/SIGIO>It may be a kernel configuration issue.
> But very frankly, there must be a better way to do that than a signal.

yes, maybe you're right. But this code works on a lot of platforms and
it would be a big deal to rewrite it.

Looking into the LogCat, there's another reference to SIGIO:
"Process 731 terminated by signal (29)"
according to asm/signal.h, 29 is SIGIO (and SIGPOLL = SIGIO)

the last line in the dmesg-output is: "<6>binder: 818:818 transaction
failed 29189, size 88-0"

what did you mean with "kernel configuration issue"?

David Turner

unread,
Mar 26, 2010, 1:51:00 PM3/26/10
to andro...@googlegroups.com
On Fri, Mar 26, 2010 at 3:22 AM, Stefan Krecher <stefan....@googlemail.com> wrote:
On Mar 26, 2:57 am, David Turner <di...@android.com> wrote:
> According to Wikipedia, SIGIO == SIGPOLL and does only work with poll()
>
> http://en.wikipedia.org/wiki/SIGIO
>
> <http://en.wikipedia.org/wiki/SIGIO>It may be a kernel configuration issue.
> But very frankly, there must be a better way to do that than a signal.

yes, maybe you're right. But this code works on a lot of platforms and
it would be a big deal to rewrite it.

Looking into the LogCat, there's another reference to SIGIO:
"Process 731 terminated by signal (29)"
according to asm/signal.h, 29 is SIGIO (and SIGPOLL = SIGIO)

Ah, did you install a signal handler for SIGIO ? If not that could explain it.
 
the last line in the dmesg-output is: "<6>binder: 818:818 transaction
failed 29189, size 88-0"

what did you mean with "kernel configuration issue"?


It means that the problem might be that the kernel is not configured to handle SIGPOLL in the same way.
I really don't know, what this means is that I don't see why there would be something in the user-level system
that prevent this to work.
Reply all
Reply to author
Forward
0 new messages