I'm trying to use the Boxee Remote Control Interface to send a UDP Broadcast to discover devices.
Currently using AsyncUdpSocket
but when sending the request, i just get the request back as the response, instead of getting the expected response.
Here's my code, Am I missing anything? :
- (void)viewDidLoad
{
[super viewDidLoad];
AsyncUdpSocket *socket = [[AsyncUdpSocket alloc] initWithDelegate:self];
[socket enableBroadcast:YES error:nil];
[socket bindToPort:2562 error:nil];
NSString *xml = @"<?xml version=\"1.0\"?><BDP1 cmd=\"discover\" application=\"iphone_remote\" challenge=\"shittycitttyy123\" signature=\"cdddac43fdbce83d24b7c1ca5149c697\"/>";
NSData *data = [xml dataUsingEncoding:NSUTF8StringEncoding];
if([socket sendData:data toHost:@"10.0.0.255" port:2562 withTimeout:3 tag:0]){
[socket receiveWithTimeout:2 tag:0];
}
}
-(BOOL)onUdpSocket:(AsyncUdpSocket *)sock didReceiveData:(NSData *)data withTag:(long)tag fromHost:(NSString *)host port:(UInt16)port{
NSLog(@"Got data %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
return YES;
}