Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Raw Socket on Vxworks

373 views
Skip to first unread message

Navin Kumar Agrawal

unread,
Mar 1, 2000, 3:00:00 AM3/1/00
to
Tornado


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

Peter Colby

unread,
Mar 2, 2000, 3:00:00 AM3/2/00
to
try

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.

Thomas Davis

unread,
Mar 2, 2000, 3:00:00 AM3/2/00
to

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!

0 new messages