Thread: Socket programming problem.

  1. #1
    Unregistered
    Guest

    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
    Posts
    35
    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
    Unregistered
    Guest
    Sorry I am also a newby, however, there are tonnes of resources from the Internet. Here is some urls I use
    http://www.cm.cf.ac.uk/Dave/C/CE.html
    http://www.ecst.csuchico.edu/~chafey/
    http://pont.net/socket/

    Good luck

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    35
    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
    Posts
    7

    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 "127.0.0.1" 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 [email protected] 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, 04:46 AM
  3. Problem with network code
    By cornholio in forum Linux Programming
    Replies: 1
    Last Post: 12-20-2005, 01: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, 10:01 AM