Re: Winsock connection
- From: Tony Hedge <tonyatbenthicsciencesdotcodotuk>
- Date: Mon, 04 Feb 2008 11:42:02 +0000
Cri
I've recently faced a similar problem, but only the server 'end' of it - you might find my observations helpful, even though I don't know all the answers at the client 'end'.
Winsock is an implementation of Sockets, which works on the principle of clients and servers.
If you are writing the server 'end' on a machine with multiple adapters, you can specify which ip address to use in the app, or implement multiple servers, one per adapter, either as separate apps, or as a single app.
If you are writing the client 'end' on a machine with multiple adapters, it gets a bit trickier. The client application will use the best route available to it in the routing table - you can't (to the best of my knowledge) specify which adapter to use at the application level, you need to play around with the routing table etc. Normally though, you wouldn't have both adapters configured to the same subnet, so only one would have a route to your server.
Try looking in the documentation for Socket Client/Server examples and for the IPHelper API functions. Unfortunately the example code for both is a bit flaky.
Good luck, hope this gets you thinking in the right direction.
Tony
Cri++ wrote:
I'm using the "winsock" library in evC++ 4.0..
My device is a WinCE 4.2 PC.
The device have 2 ethernet cards RTL80391 and RTL80392 and every card
have an IP address.
The follow software open a connection and work correctly:
SOCKET g_Sock;
sockaddr* g_p_sock_address;
g_Sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
connect(g_Sock, g_p_sock_address, sizeof(struct sockaddr));
After I'm able to send and receive with:
g_SentLen = send(g_Sock, QueryBuf, QueryBufLen, 0);
// ...
g_RecLen = recv(g_Sock, g_ResponseBuf, sizeof(g_ResponseBuf), 0);
My question is:
can I select witch card (RTL80391 or RTL80392) to use for
communicate? Or the socket auto-select the card.
A connection is composed like
(IP source, Port source --- IP dest., Port dest.),
when a connection is open with "connect" istruction
I can specify the destination IP address but not the source IP address.
Sombody know if can I select the source IP address?
Thanks
- Follow-Ups:
- Re: Winsock connection
- From: Tony Hedge
- Re: Winsock connection
- Prev by Date: Re: Where to find the PKTOpenAdapter (PNDIS_STRING) parameter
- Next by Date: Re: Winsock connection
- Previous by thread: Re: Where to find the PKTOpenAdapter (PNDIS_STRING) parameter
- Next by thread: Re: Winsock connection
- Index(es):
Relevant Pages
|