0

I'm trying to send a data using UDP socket and capture the data using a wireshark (under Windows7):

client_sockd= socket(AF_INET,SOCK_DGRAM,IPPROTO_IP);    
client_address.sin_family = AF_INET;
client_address.sin_addr.s_addr = inet_addr("192.168.3.100");
client_address.sin_port=htons(8015);
client_len=sizeof(client_address);
int sended = sendto(client_sockd,buf,11,0,(const struct sockaddr *)&client_address,sizeof(client_address));

it's sending the packet to the correct ip but dest port becoming 2698. i'm trying to change the port in my code, but it doesnot have any effect to the real destination port. It's still to be 2698. How can i fix it?

qmor
  • 568
  • 6
  • 20

1 Answers1

0

Try IPPROTO_UDP instead of IPPROTO_IP:

client_sockd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);    
huysentruitw
  • 27,376
  • 9
  • 90
  • 133
  • Thanks for answer. I've tried both variants without any positive result. – qmor May 14 '13 at 15:19
  • Are you sure your program is recompiling after you change something? What you see is VERY weird. What's your development environment? – huysentruitw May 14 '13 at 15:21
  • My development environment is eclipse with mingw. After any changes in code i made a clean and rebuild to make a sure that everithing is up to date. – qmor May 14 '13 at 15:29