Friday, September 9, 2011

mkaddr c code


There is another version of mkaddr.c subroutine which is using inet_addr. The problem with inet_addr(3) is that it returns the value INADDR_NONE when an address is invalid. When the IP address 255.255.255.255 is converted to a 32-bit value, its return value is identical to the constant INADDR_NONE. Consequently, it becomes impossible to distinguish between a bad input IP address, and the general broadcast address. Use of the inet_aton(3) function avoids this ambiguity.
Here is the complete udp broadcast client-server application

6 comments:

  1. As written, has potential memory leaks: error returns do not call free(inp_addr)

    ReplyDelete
    Replies
    1. Yes, you are correct. We will update the code soon. You can also post the suggest fix we will add your changes too.

      Thanks.

      Delete
  2. I keep getting "Undefined reference to mkaddr" when I try to compile this. What am I doing wrong?

    ReplyDelete
  3. Can you show us the code that you are using ? Seems you have missed to add the function.

    ReplyDelete