
5 if(ret < 0)
6 {
7 printf("setsockopt() failed.\n");
8 return(1);
9 }
10
11
/* handle return value using ifdefs */
12 ret = setsockopt(sd, IPPROTO_IP, IP_HDRINCL,
13 (const char *) &flg, sizeof(flg));
14 /* if Win32, check for SOCKET_ERROR constant */
15 #ifdef WIN32
16 if(ret == SOCKET_ERROR)
17 #else
18 /* otherwise, check for value less than zero */
19 if(ret < 0)
20 #endif
21 {
22 printf("setsockopt() failed.\n");
23 return(1);
24 }
Analysis
■
At lines 1 through 10, the setsockopt() function is called and the return value is
treated as an integer no matter what platform the program is compiled on.This
is permissible; however, the return value can also be compar ...