#include
#include
#include
#include
#include
#include
#include
# define SERV_PORT 80
# define SERV_IP "221.14.145.31
"
Struct ip_option_hdr {
Unsigned char code;
Unsigned char length;
Unsigned char offset.
Unsigned addrs [9].
} opthdr;
Int main (int arg c, char * argv []) {
Int sockfd;
Struct sockaddr_in servaddr;
Memset (& amp; Servaddr, 0, sizeof (servaddr));
Servaddr. Sin_family=AF_INET;
Servaddr. Sin_addr. S_addr=inet_addr (SERV_IP);
Servaddr. Sin_port=htons (SERV_PORT);
If ((sockfd=socket (AF_INET SOCK_STREAM, 0)) & lt;=0) {
Perror (" socket error: ");
exit(1);
}
Memset ((char *) & amp; Opthdr, 0, sizeof (opthdr));
Opthdr. Code=7;
Opthdr. Length=39;
Opthdr. Offset=4;
//set the socket send this option
If (setsockopt (sockfd, IPPROTO_IP IP_OPTIONS, (char *) & amp; Opthdr, sizeof (opthdr)) & lt; 0 {
Perror (" setsockopt error ");
return 0;
}
If (connect (sockfd, (struct sockaddr *) & amp; Servaddr, sizeof (servaddr)) & lt; 0 {
Perror (" connect error ");
exit(1);
}
Write (sockfd, "/n/r/r/n", strlen ("/n/r/r/n "));
Close (sockfd);
}
Strives for the solution,,,,, if the trouble can be a red envelope support,,,,
CodePudding user response:
Artificial placed at the top,,,, index of patches