News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

winsock? pointing url request to eth1 (solved)

Started by thomas_remkus, October 31, 2007, 04:29:29 AM

Previous topic - Next topic

thomas_remkus

I have an interesting task. I need to test the performance of making a web request for an http page from two different network cards. Both cards are installed and working. Running Windows XP. If I monkey with the routes I can get the page to run from either card. This is time consuming.

Is there a quick way to assign an IP to a network card? Better yet, is there a WinSock API that I can call to just specify the network device I need during a call so I don't have to mess with routing?

If I could get a push in the right direction with an API I think I can take it from there. I would love to be able to call the same page from both cards at the same time.

akane

Did you tried with socket binding to one of the network addresses (bind function) ?
QuoteIf an application does not care what local address is assigned, specify the manifest constant value ADDR_ANY for the sa_data member of the name parameter. This allows the underlying service provider to use any appropriate network address, potentially simplifying application programming in the presence of multihomed hosts (that is, hosts that have more than one network interface and address).
Note: the socket must be not connected before binding.
Also after binding to 0.0.0.0 or 127.0.0.1, the socket will operate with all network cards, binding to 12.34.56.78 will (should) restrict the socket to use only one card with IP 12.34.56.78.
Specify 0 as the port in sockaddr_in to bind on random port, it has no meaning on non-listening sockets.

thomas_remkus

That's what I was looking for exactly! Thanks for the pointers.