I am using UDP BSD sockets in my program, all is working just fine until my computer has two nics or 1 nic and one virtual nic. I am running Linux x86 Debian Squeeze.
I have one nic pointed at my 10.0.0. network and another one at 10.13.0. network
My outbound packets are making it to the destination on my 10.13.0 network.
The problem is that the computer on the 10.13.0 network that im sending to tries to send an ACK back but it sees my address as being my 10.0.0. address but packets cannot route from the 10.13.0. to the 10.0.0. network. If it saw my address as being from the 10.13.0. network it would work fine.
When creating the udp sockets can I specify what source address to use?
Thanks in advance,
Adam
Here is how I am implementing the sending so far:
Expand|Select|Wrap|Line Numbers
- memset(&hints, 0, sizeof hints);
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
- if ((rv = getaddrinfo(host.c_str(), po, &hints, &servinfo)) != 0) {
- throw "getaddrinfo failed";
- }
- // loop through all the results and make a socket
- for (p = servinfo; p != NULL; p = p->ai_next) {
- cout << "**Addr:" << p->ai_addr->sa_data << endl;
- if ((sockfd = socket(p->ai_family, p->ai_socktype,
- p->ai_protocol)) == -1) {
- continue;
- }
- break;
- }
- if (p == NULL) {
- throw "failed to bind to socket";
- }
- if ((numbytes = sendto(sockfd, msg.c_str(), msg.length(), 0,
- p->ai_addr, p->ai_addrlen)) == -1) {
- return numbytes;
- }
- freeaddrinfo(servinfo);
- close(sockfd);