I am trying to Implement Banjour based application in ios. I implement success fully also sending and receiving data to one iphone to another iphone. After browsing the services all other device in the work. and display in to the Table.
Now i want to select some devices in the table view, and send data to the selected devices
For that i created only one socket in each device.
CFSocketContext socketCtxt = {0, self, NULL, NULL, NULL};
witap_socket = CFSocketCreate(kCFAllocatorDefault, PF_INET6, SOCK_STREAM, IPPROTO_TCP, kCFSocketAcceptCallBack, (CFSocketCallBack)&TCPServerAcceptCallBack, &socketCtxt);
if (witap_socket != NULL)
{
protocolFamily = PF_INET6;
}
else
{
witap_socket = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_STREAM, IPPROTO_TCP, kCFSocketAcceptCallBack, (CFSocketCallBack)&TCPServerAcceptCallBack, &socketCtxt);
if (witap_socket != NULL)
{
protocolFamily = PF_INET;
}
}
now i want to send data to the selected devices. for that I stored selected NSNetService(ie devices) another NSMutableArray. When used Click the send button particular Action will invoked.
-(void)SendActionFunction
{
for(int idx=0;idx<[selectedSer count];idx++)
{
NSNetService *service = [self.selectedSer objectAtIndex:idx];
NSLog(@"service......%@",[service name]);
self.currentResolve = [self.selectedSer objectAtIndex:idx];
[self.currentResolve setDelegate:self];
[self.currentResolve resolveWithTimeout:0.0];
}
}
if i am trying to Resolve address for each device(above code). It will resolve only for first device. and getting error
- (Error code=-72003]
one more problem if i resolved address for a device it automatically remove from Tableview.
So my doubts are:
- Why the selected device revoved?
- Now i create TCP based socket, How to add destination address to send data?
- Is it possible to send data from single socket to multiple destination?