Hi all,
I have a basic(for most of you) question.
I´m trying to make a very simple app that will have 1 button (for example) and when its pushed the app will create a socket connection with a host and will send it a message.
So , i have found this on ADC:
but i dont realy understand where i have to put the ip of the host (192.168.1.10) and how can i define iStream and oStream.
Just to mention that 192.168.1.1 already have opened socket and are always listening a specified port.
All your help will be apreciated.
I have a basic(for most of you) question.
I´m trying to make a very simple app that will have 1 button (for example) and when its pushed the app will create a socket connection with a host and will send it a message.
So , i have found this on ADC:
Code:
- (IBAction)searchForSite:(id)sender
{
NSString *urlStr = [sender stringValue];
if (![urlStr isEqualToString:@""]) {
[searchField setEnabled:NO];
NSURL *website = [NSURL URLWithString:urlStr];
if (!website) {
NSLog(@"%@ is not a valid URL");
return;
}
NSHost *host = [NSHost hostWithName:[website host]];
// iStream and oStream are instance variables
[NSStream getStreamsToHost:host port:80 inputStream:&iStream
outputStream:&oStream];
[iStream retain];
[oStream retain];
[iStream setDelegate:self];
[oStream setDelegate:self];
[iStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[oStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[iStream open];
[oStream open];
}
}
Just to mention that 192.168.1.1 already have opened socket and are always listening a specified port.
All your help will be apreciated.