Skip to contentSkip to conversation

getprotobyname failure

DISCUSSION Yigit Can 2 participants 2 messages Feb 25, 2003 – Feb 26, 2003

lore
Share & tools
lore

Yigit Can

author
#0 lore raw

Hello,

I have a problem with getprotobyname() function.

I wrote a simple program that only uses getprotobyname function

I can run this program on my development machine=20
but when I try to run this program on my basic kernel it gives me the = "memory fault" error.

I'm using libc-2.2.5 on a powerpc 8xx development kit so, i'm using the same library on the host and target machine.

my development machine has celeron type processor and my target board is TQM850L (has ppc_850 processor).

I've replaced my protocols and nsswitch.conf files with host machines (my protocols file contians "tcp 6 TCP" line)
and that's made no difference.

what can I do?

please help,

my program :

#include <netdb.h>
#include <stdio.h>

int main(void){

    struct sockaddr_in addr;
    struct protoent *protocol=3DNULL;
    protocol=3Dgetprotobyname("tcp");
    printf("\n RESULT : %02x \n",protocol->p_proto);
 
    return 0;
}

Yigit CAN
Karel Electronics Corp.
[email protected]

#1 lore raw
Quoted 8 lines · Yigit Can

I have a problem with getprotobyname() function.

I wrote a simple program that only uses getprotobyname function

I can run this program on my development machine
but when I try to run this program on my basic kernel it gives me the "memory fault" error.

Quoted 5 lines

I'm using libc-2.2.5 on a powerpc 8xx development kit so, i'm using the same library on the host and target machine.

my development machine has celeron type processor and my target board is TQM850L (has ppc_850 processor).

I presume that you have managed to get other programs to work by cross-compiling, right?

Quoted 14 lines

I've replaced my protocols and nsswitch.conf files with host machines (my protocols file contians "tcp 6 TCP" line)
and that's made no difference.

what can I do?

please help,

my program :

#include <netdb.h>
#include <stdio.h>

Quoted 6 lines

int main(void){

    struct sockaddr_in addr;
    struct protoent *protocol=NULL;
    protocol=getprotobyname("tcp");
    printf("\n RESULT : %02x \n",protocol->p_proto);

You should check that the pointer which getprotobyname() returns is non-NULL before trying to dereference it.

Signature · 1 line
Glynn Clements <[email protected]>