• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Multihoming problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multihoming problem


  • Subject: Multihoming problem
  • From: "peiyuan" <email@hidden>
  • Date: Wed, 27 Feb 2008 16:41:34 +0800

Hi all,
 
I am now trying to send data from a Mac to two different network.
 
My Mac has two ips.
 
192.168.0.234 (LAN)
192.168.1.56 (Wireless)    ==============>    some place 192.168.1.33
 
My code is listed below partially:
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr("192.168.1.56");    //If I use INADDR_ANY, it didn't send using both NIC. Why?
sin.sin_port = htons(1234);
 
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
 
setsockopt(s, SOL_SOCKET, SO_BROADCAST, (const void *)&opt, sizeof(opt));
 
bind(s, (struct sockaddr *)&sin, sizeof(sin));
 
send_sin.sin_family = AF_INET;
send_sin.sin_addr.s_addr = inet_addr("255.255.255.255");
send_sin.sin_port = htons(1234);
 
mydata.data1=2;
mydata.data2=3;
 
int sendtoResult;
sendtoResult = sendto(s, (const void *)&mydata, sizeof(mydata), 0, (struct sockaddr *)&send_sin, sizeof(send_sin) );
 
while(1)
{
  if (recvfrom(s, buff, sizeof(buff), 0, (struct sockaddr *)&recv_sin, &recvlen) < 0)
  {
    printf("Receive error!!!\n");
  }
}
 
 
My problems are:
1. In binding, I use
                sin.sin_addr.s_addr = inet_addr("192.168.1.56");
    However, this is not working. It didn't receive any data. I have to change to sin.sin_addr.s_addr = INADDR_ANY;
    What I want to achieve is that
        A. Since I have two cards, sometimes I only want to use the wireless card or LAN to receive and send packet.
        B. I want to send data on both card.
 
So, how?? What's wrong with my code?
           
 
 
2. When I send data, only the LAN side will broadcast. The wireless side didn't send any data. I know that because the "192.168.1.33" didn't receive any packet from 192.168.1.56
 
DATA = "" 192.168.0.234(LAN)       =====Broadcast=====>  ok
          = >  192.168.1.56(Wireless)   ===============X    Why???   192.168.1.33
 
 
Any suggestions?
How should I write it?
 
Thank you.
 
Pei-Yuan
@KCodes
 
 
 
 
 
 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Multihoming problem
      • From: "Hamish Allan" <email@hidden>
  • Prev by Date: Create new PPP service
  • Next by Date: Re: Multihoming problem
  • Previous by thread: Re: Create new PPP service
  • Next by thread: Re: Multihoming problem
  • Index(es):
    • Date
    • Thread