NSURL tunneling
NSURL tunneling
- Subject: NSURL tunneling
- From: John <email@hidden>
- Date: Sun, 20 Mar 2005 11:57:03 -0500
I'm having trouble getting data from a networked Device - connecting to
it is as follows:
"All you need to do is enable the tunnel port in the Device and then
open a TCP connection from your PC to the IP address of the module at
port 8023. At that point any data sent to the serial port will be
packetized and sent over the TCP connection."
Now, I've used the following code*** to download apple's source code
and output it to a text field:
NSString *theURL =[[NSURL alloc]
initWithString:@"http://www.apple.com"];
NSString *result = [NSString stringWithContentsOfURL:theURL];
[urlTextField setString:result];
OR this code:
NSURL *url = [NSURL URLWithString:@"http://www.apple.com"];
NSMutableURLRequest *request = [NSMutableURLRequest
requestWithURL:url];
[request setCachePolicy:NSURLRequestReloadIgnoringCacheData];
[request setTimeoutInterval:20.0];
NSURLResponse *response;
NSData *data = [[NSData alloc] initWithData:[NSURLConnection
sendSynchronousRequest:request returningResponse:&response error:nil]];
if ( data != nil )
{
NSString *html = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
[data release];
[urlTextField setString:html];
if ( html != nil )
{
// whatever
[urlTextField setString:@"no data"];
}
}
Now I try to connect to my device, and do the same.
I change the URLWithString to:
http://192.168.0.100:8023
and make sure the following are set in the Device:
Enable TCP direct tunnel on specified tunnel port : YES
TCP listen port to tunnelling : 8023
And my app hangs. I plug the same URL into Safari - nothing loads. I
plug the URL into Firefox - it loads the data, and continues to do so
as new data is received.
What am I doing wrong? I'm thinking it never loads the data because it
is continuously loading. The data is just text, what would normally be
output by a serial port.
This is a sample of the text that is output:
0, 0, 11, 0, 1, 44, 0, 0, 3265
0, 0, 11, 0, 0, 0, 0, 0, 3265
0, 0, 11, 0, 0, 0, 0, 0, 3265
and so on.
Thanks!
John Pariseau
***from the web
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden