[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: help with a simple C program



On Sat, Jun 03, 2000 at 11:58:50PM +1000, Shao Zhang wrote:
> Hi,
>     Could anyone explain to me why the following C program always fails?
>     I mean the setsockopt always fails. Thanks for the help.
> 
>     Thanks for any help in advance.
> 
>     sd = socket(AF_INET, SOCK_DGRAM, 0); /* 0 for IP protocol */
>     error = setsockopt(sd, SOL_SOCKET, SO_BROADCAST, (char *) &f, 1);
>     if (error == -1)
>         printf("setsockopt on %d failed!!\n", sd);

According to the setsockopt(2) man page, you should probably be using an
int for f.  This makes the length be 4, which makes the program work for
me.  Of course, I'm not a socket programming expert by any means, so
take this with a grain of salt.

Cheers,
Chris

-- 
pick, pack, pock, puck: like drops of water in a fountain falling
softly in the brimming bowl.



Reply to: