Click to See Complete Forum and Search --> : INADDR_BROADCAST n INADDR_ANY


majidpics
12-05-2002, 07:26 AM
i m in trouble

when i use htonl(INADDR_BROADCAST) and use sendto() message it returns the error of hostunreachable. while in case of INADDR_ANY it successfully returns.

One more thing on the recieving side when i use to recieve data by using recvfrom() it waits infinitely and not recieving data.I have checked that port is successfully bound.But all in vain.

Ddruid
12-06-2002, 10:23 PM
Originally posted by majidpics
when i use htonl(INADDR_BROADCAST) and use sendto() message it returns the error of hostunreachable. while in case of INADDR_ANY it successfully returns.

Did you set the socket options to allow it to send to the broadcast address? man setsockopt, 7 socket. Look for information pertaining to SO_BROADCAST.

One more thing on the recieving side when i use to recieve data by using recvfrom() it waits infinitely and not recieving data.I have checked that port is successfully bound.But all in vain.
Read up on Non-blocking I/O, mainly how to use 'select'. Have a look at
Beej's Guides (http://www.ecst.csuchico.edu/~beej/guide/)