Thread: Socket programming problem.

  1. #1

    Question Socket programming problem.

    Hi all,
    I am using GCC compiler/Sun Solaris.
    I would like to ask in <arpa/inet.h> library, what ip address does the constant "INADDR_BROADCAST" and "INADDR_ANY" represent? What is the effect of binding a socket to these addresses?
    Any idea is appreciated, thanks a lot!

    ~~~~~~~~~~~Here is my code~~~~~~~~`
    struct sockaddr_in servAddr;
    servAddr.sin_family = AF_INET;
    servAddr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
    servAddr.sin_port = htons(1500);
    servLen = sizeof(servAddr);
    if(bind(sd, (struct sockaddr *) &servAddr, servLen)<0) {
    perror("\nERROR : Failed to bind socket for the Listener ");
    return ERROR;

  2. #2
    Registered User
    Join Date
    Aug 2001
    um well i can't really help you but could you tell me a good winsock programming book in C to get please?

  3. #3
    Sorry I am also a newby, however, there are tonnes of resources from the Internet. Here is some urls I use

    Good luck

  4. #4
    Registered User
    Join Date
    Aug 2001
    Eek too much unix, even though unix is way cooler then dos, i am running windows so i guess it won't work.

  5. #5
    Registered User
    Join Date
    Oct 2002

    Quite simple....

    Binding takes the socket and ties the host address and port information together, letting you then to listen() for incoming connections. INADDR_ANY means, that any address can be used to start the server. Some people replace INADDR_ANY with "" which is the localhost, but either way, you have to bind it to the computer that the server is being run on. Its always best to use INADDR_ANY. ANyways, this is an old thread, so you will probably never read it. BUT, if anyone out there catches this message, and is wanting to learn Winsock programming, the simple way, email and If i get enough feedback, I will write a tutorial (simple, but thourough.)Peace.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Non-blocking socket connection problem
    By cbalu in forum Linux Programming
    Replies: 25
    Last Post: 06-03-2009, 02:15 AM
  2. socket message sending and receiving problem
    By black in forum C Programming
    Replies: 5
    Last Post: 01-15-2007, 03:46 AM
  3. Problem with network code
    By cornholio in forum Linux Programming
    Replies: 1
    Last Post: 12-20-2005, 12:21 AM
  4. sockets problem programming
    By kavejska in forum C Programming
    Replies: 0
    Last Post: 07-25-2005, 07:01 AM
  5. Client/Server Socket Receive Problem
    By mariabair in forum Networking/Device Communication
    Replies: 6
    Last Post: 12-25-2003, 09:01 AM