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.