> OK tried it running as Su
>

i.e root@beaglebone\ ./myproj       

 the executable runs but I am guessing the problem persists as it picks up 
the wifi IP address still 

So this is telling me that  SO_BINDTODEVICE does not work ????? or I am 
doing something else wrong - but everything that goes to the wifi is 
correct just the wrong device.

my code :

                struct sockaddr_in addr;
                char* interface = "eth0";

if((socketId = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
currentConnection = -1;
 //return 1;
}


struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), interface);

ioctl(.socketId, SIOCGIFINDEX, &ifr);
error = setsockoptsocketId, SOL_SOCKET, SO_BINDTODEVICE,  (void*)&ifr, 
sizeof(ifr));


memset(&addr.addr, 0, sizeof(addr.addr));

addr.addr.sin_family = AF_INET;
addr.addr.sin_port = htons(TCP_DATA);

if (ipaddr != NULL)
{
if( inet_pton(AF_INET, ipaddr, &addr.addr.sin_addr) <=0 )
currentConnection = -1;
}
else
{
if(inet_pton(AF_INET, hostIP, &addr.addr.sin_addr)<=0)
currentConnection = -1;
}

if (currentConnection!=-1)
{
/* So that we can re-bind to it without TIME_WAIT problems */
setsockopt(socketId, SOL_SOCKET, SO_REUSEADDR, &addr.addr, 
sizeof(addr.addr));
setnonblocking(socketId);

status = connect(socketId, (struct sockaddr *)&addr.addr, 
sizeof(addr.addr));


                                    .....
                       }

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to