sento() fails to send packet to 127.0.0.1 with errorcode 10049 in windows 7 same works on windows xp
1.
We have a socket which is bound to the local IP address of the machine i.e the IP of the machice on which the application is running.
The sample code is as pasted below,
s = socket(PF_INET, SOCK_DGRAM, 0);
bool reuse = 1;
struct sockaddr_in srv_addr;
memset(&srv_addr,0,sizeof(srv_addr));
srv_addr.sin_family = PF_INET;
srv_addr.sin_addr.s_addr = inet_addr(ipaddr);
srv_addr.sin_port = htons(port); // example port is 7000
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&reuse, sizeof(reuse));
bind(s, (LPSOCKADDR)&srv_addr, sizeof(srv_addr));
2. There is another piece of code where we write data; The same socket created above then is used in sendto() like below
sendto(s, msg, bytesToSend, 0, (SOCKADDR *)&Addr, sizeof(Addr));
The send to function fails with error code 10049; The same code used to work on WinXP
below is the way in which the Addr, sturcture is filled
Note: we have used the loopback address
memset(&Addr,0,sizeof(Addr));
Addr.sin_family = AF_INET;
Addr.sin_addr.s_addr = inet_addr("127.0.0.1" ); //Will be in Network Byte Order
Addr.sin_port = htons(port); //same port as the one mentioned in step 1; example 7000
memset(&(replicationAddr.sin_zero), '\0', 8); // zero the rest of the struct
Has anyone faced this issue and found the reason for it. Also is there any workaround for this?
Thanks.
July 20th, 2012 3:19am
1. Perhaps the developer forum is better platform for your problem
2. sento() in heading is typo error
3. Syntax
http://msdn.microsoft.com/en-us/library/windows/desktop/ms740148(v=vs.85).aspx
4. Error codes
http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx
Rgds
Milos
Free Windows Admin Tool Kit Click here and download it now
July 20th, 2012 5:03am
1. We have a socket which is bound to the local IP address of the machine i.e the IP of the machice on which the application is running.
The sample code is as pasted below,
s = socket(PF_INET, SOCK_DGRAM, 0);
bool reuse = 1;
struct sockaddr_in srv_addr;
memset(&srv_addr,0,sizeof(srv_addr));
srv_addr.sin_family = PF_INET;
srv_addr.sin_addr.s_addr = inet_addr(ipaddr);
srv_addr.sin_port = htons(port); // example port is 7000
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&reuse, sizeof(reuse));
bind(s, (LPSOCKADDR)&srv_addr, sizeof(srv_addr));
2. There is another piece of code where we write data; The same socket created above then is used in sendto() like below
sendto(s, msg, bytesToSend, 0, (SOCKADDR *)&Addr, sizeof(Addr));
The send to function fails with error code 10049; The same code used to work on WinXP
below is the way in which the Addr, sturcture is filled
Note: we have used the loopback address
memset(&Addr,0,sizeof(Addr));
Addr.sin_family = AF_INET;
Addr.sin_addr.s_addr = inet_addr("127.0.0.1" ); //Will be in Network Byte Order
Addr.sin_port = htons(port); //same port as the one mentioned in step 1; example 7000
memset(&(replicationAddr.sin_zero), '\0', 8); // zero the rest of the struct
The firewall is already disabled
Has anyone faced this issue and found the reason for it. Also is there any workaround for this?
Thanks.
July 23rd, 2012 7:36am
Are you sure your port is right? Maybe port is zero?
Free Windows Admin Tool Kit Click here and download it now
July 23rd, 2012 1:06pm
Hi shraddha_k,
I found you have posted a similar thread in Windows 7 Networking forum. I'd like to merge them to keep in the same topic.
Thanks for your understanding.
Best regards,Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
July 24th, 2012 2:17am
Yes, the port is correct. it is not zero
Free Windows Admin Tool Kit Click here and download it now
July 24th, 2012 2:28am
Hi Helen,
If you see the thread above, Milos had asked me to post this question in the Developer forum as it is much more relevant there. I would appreciate it to be kept there itself so that I get my query answered
Thanks
July 24th, 2012 4:51am