|
-
December 10th, 2003, 04:25 AM
#1
Advaced Winsock Problem: using winsock2 bind() to bind to interface
Thanks for everyone's reply in advance.
I am writing a network application on WinXP, and it needs to ping a particular server with different interfaces. For example, I'd like to ping google.com from my ethernet connection or wireless connection when I have both of them connected to the internet. I have searched extensively on the net, and the only solution I found was to use WSAIoctl(...) with SIO_ADDRESS_LIST_QUERY or SIO_GET_INTERFACE_LIST in the parameter, then obtain the interface information. What I did was constructing raw packets using socket(AF_NET, SOCK_RAW, IPROTO_ICMP), and the ping program works well before I tried to change the interface. I also have administrator right to construct raw packets.
I have no problem with the above. I have successfully obtained the interface and used bind() to bind to the socket(I have also checked the return error code). This is the troubling part. The default connection is Ethernet with IP 192.168.0.101, and my wireless IP is 192.168.0.102. When I bind the socket to my wireless interface, it sends out the ping through my ethernet interface but with the source IP of my wireless IP. That means, it sends out the packet with header 192.168.0.102 through the ehternet interface having IP 192.168.0.101. The wireless connection receives the ping echo reply though, because that is the source address for the ping request. This really troubles me and I cannot find any solution. One solution is the modify the routing table before each ping, but I need another connection to the host already, so modifying the routing table to that host will terminate my other connection which is not a feasible solution for me.
Is there anyone who can give some suggestion? Thanks a lot.
Sorry for posting twice. I think the problem fits better in this forum but I couldn't delete the other post.
-
December 10th, 2003, 12:06 PM
#2
Have you enabled IP forwarding on your computer?
This might cause your symptoms.
See IPEnableRouter in MSDN and your registry.
Beware: Disabling it might cripple your computer if it is used for RAS.
The Saviour of the World is a Penguin and Linus Torvalds is his Prophet.
-
December 11th, 2003, 04:56 PM
#3
Thanks for the help. I have tried disabling IPEnableRouter, but the results were the same. I understand that windows uses only the routing table to determine which interface it sends from regardless of the source IP. However, is there a way to get around this problem? I have a post on the newsgroup,
http://groups.google.com/groups?hl=z....de%26rnum%3D1
Any ideas? Thanks~~
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|