help with a simple C program
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.
Regards,
Shao.
=====cut here======
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
int main(void)
{
    int sd, error;
    const char f = 1;
    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);
    close(sd);
    return 0;
}
-- 
____________________________________________________________________________
Shao Zhang - Running Debian 2.1  ___ _               _____
Department of Communications    / __| |_  __ _ ___  |_  / |_  __ _ _ _  __ _ 
University of New South Wales   \__ \ ' \/ _` / _ \  / /| ' \/ _` | ' \/ _` |
Sydney, Australia               |___/_||_\__,_\___/ /___|_||_\__,_|_||_\__, |
Email: shao@cia.com.au                                                  |___/ 
_____________________________________________________________________________
Reply to: