Hi Folks,
I would really appreciate if somebody can help me in solving a problem
of
mine which is related with the usage of Raw Socket on VxWorks. I have
put my effort in the following way.
--------------------------------------------------------
struct sockaddr_in serveraddr;
bzero ((char *)&serveraddr, sizeof(struct sockaddr_in));
serveraddr.sin_family = AF_INET;
serveraddr.sin_len = sizeof(struct sockaddr_in);
serveraddr.sin_port = htons (6007);
serveraddr.sin_addr.s_addr = htonl (inet_addr ("192.168.100.140"));
if ((fd = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP)) == ERROR)
{
perror ("socket");
return -1;
}
if (bind (fd, (struct sockaddr *)&serveraddr, sizeof(struct
sockaddr_in)) == ERROR)
{
perror ("bind failed");
return -1;
}
--------------------------------------------------------
My target system is based on PPC604 (PowerPC). On executing the above
program,
it is failing at bind () and the error code returned is
EADDRNOTAVAIL ("Can't
assign requested address").
Can anybody help me in sovling this problem?
Regards,
Navin
serveraddr.sin_addr.s_addr = inet_addr ("192.168.100.140");
(in other words, I don't believe that htonl is necessary)
or you might want to try mucking around with hostent if vxWorks
has it.
Peter is right, htonl is not needed because ip address are not numbers
they are 4 bytes that are just easy to carry around that way.
Thomas
--
Galois, Inc.
http://www.galois.net
We color the world!