Wednesday, October 5, 2011

htons function in c


See Also
  1. htonl
  2. ntohl
  3. ntohs

1 comment:

  1. The following changes will make the compiler happy :}
    I used gcc='gcc -O3 -ggdb -std=c99 -Wall -Wextra -D_BSD_SOURCE '

    From: gcc htons-example.c -o htons-example
    To: gcc -D_BSD_SOURCE htons-example.c -o htons-example

    From: int len_inet;
    To: unsigned int len_inet;

    From: z = getsockname(s, (struct sockaddr *)&adr_inet, &len_inet);
    To: z = getsockname(s, (struct sockaddr *restrict)&adr_inet, &len_inet);

    Thanks for the nice example code - Enjoyed!

    ReplyDelete