14
15
#include <winsock2.h>
16 #include <ws2tcpip.h>/* required for IP_HDRINCL option */
17
18
#else
19
20
/* UNIX header files */
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <netinet/in.h>
24
25
#endif
26
27
#include <stdio.h>
28
29
int
30 main(void)
31 {
32 #ifdef WIN32
33 WSADATA wsa; /* used by WSAStartup() */
34 SOCKET sd = 0;
35 #else
36 int sd = 0;
37 #endif
38
39
int flg = 1;
40 int ret = 0;
41
42
/* must initialize winsock if on win32 platform */
43 #ifdef WIN32
44 memset(&wsa, 0x0, sizeof(WSADATA));
45
46
if(WSAStartup(MAKEWORD(2, 0), &wsa) != 0x0)
47 {
48 printf("WSAStartup() failed.\n");
49 return(1);
50 }
51 #endif
52
53
/* create TCP raw socket */
54 sd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
55 /* if Win32, check for INVALID_SOCKET constant */
56 #ifdef WIN32 ...