Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
BlackBerry Development Advisor
elena_laskavaia
Posts: 417
Registered: ‎10-27-2010
My Device: PlayBook

Re: socket() gives an error

That is BlackBerry security tricks. I don't have any information on why it is that way or any doc pointers.

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: socket() gives an error

Sad. But thank you.

Please use plain text.
BlackBerry Development Advisor
elena_laskavaia
Posts: 417
Registered: ‎10-27-2010
My Device: PlayBook

Re: socket() gives an error

Actually this is standard unix behaviour. Google for "Why root permissions required for creating of RAW Socket"

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: socket() gives an error

 >Actually this is standard unix behaviour. Google for "Why root permissions required for creating of RAW Socket"

 

heh.. indeed, I went backwards - looked at ping's source code and assumed that it is allowed to everybody (who runs ping) and did not notice that ping has setuid bit set.

Thanks a lot Elena, I'll proceed with my experiments with different types of sockets.



Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: socket() gives an error

Hi Elena,

again no luck although with different error, both:

	struct protoent *prot;
	struct sockaddr_in sa;
	prot = getprotobyname("udp");
	if ( !prot ){
		perror( "Error when calling getprotobyname.");
		return -1;
	}
    int sk = socket (AF_INET, SOCK_DGRAM, prot->p_proto);
    if ( sk < 1 ){
        perror("Error when creating socket");
        return -1;
    }

and

	struct protoent *prot;
	struct sockaddr_in sa;
	prot = getprotobyname("tcp");
	if ( !prot ){
		perror( "Error when calling getprotobyname.");
		return -1;
	}
    int sk = socket (AF_INET, SOCK_STREAM, prot->p_proto);
    if ( sk < 1 ){
        perror("Error when creating socket");
        return -1;
    }<

give the same "Error when creating socket: No such file or directory"

Thanks,

Evgeny

 

Please use plain text.
BlackBerry Development Advisor
elena_laskavaia
Posts: 417
Registered: ‎10-27-2010
My Device: PlayBook

Re: socket() gives an error

Change to
    if ( sk == -1 ){
Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: socket() gives an error

Sure. Stupid me. I do apologize. -(

And thanks.

Please use plain text.