question

16783621 avatar image
0 Votes"
16783621 asked ·

win10 winsock sendto error

i want to send 44 bytes of data , and i use sendto , and return 44 , but The data was not actually sent . i donot konw why ?

 WSAStartup(MAKEWORD(2, 2), &wsaData); 
 sockRaw = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); 
 DWORD bOpt = TRUE; 
 setsockopt(sockRaw, IPPROTO_IP, IP_HDRINCL, (const char*)&bOpt, sizeof(bOpt)); 
 // ... struct sockaddr_in dest;
 memset(&dest, 0, sizeof(dest)); 
 dest.sin_family = AF_INET; 
 dest.sin_port = htons(dest_port); // 先起始端口把。 
 // 设置目标地址。
 if ((dest.sin_addr.s_addr = inet_addr(dest_host)) == INADDR_NONE) 
 { 
      if ((hp = gethostbyname(dest_host)) != NULL)  
     {
         memcpy(&(dest.sin_addr), hp->h_addr_list[1], hp->h_length); 
         dest.sin_family = hp->h_addrtype; 
         printf("dest.sin_addr = %s \n", inet_ntoa(dest.sin_addr)); 
     }
     else
     {}
 }  
 char nmap_syn[] = { 0x45, 0x00, 0x00, 0x2c, 0x8a, 0x0e, 0x00, 0x00, 0x29, 0x06, 0x00, 0x00, 0xc0, 0xa8, 0x00, 0x6a, 0xc0, 0xa8, 0x00, 0x46, 0x89, 0x08, 0x00, 0x50, 0x48, 0x95, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4 }; 
 sendto(sockRaw, nmap_syn, sizeof(nmap_syn), 0, (struct sockaddr*)&dest, sizeof(dest)); 
winapi-sdk
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


How did you determine that the data was not actually sent?

0 Votes 0 ·

Hello, @16783621

Please check the return value of each api. If an api fails to return, please check the error code.
If possible, please provide a code sample that can reproduce the problem.

0 Votes 0 ·

0 Answers