Trouble with SOCKS proxies using NSStream
Trouble with SOCKS proxies using NSStream
- Subject: Trouble with SOCKS proxies using NSStream
- From: Samuel Tesla <email@hidden>
- Date: Sun, 16 Jan 2005 01:04:32 -0600
I originally posted this on the cocoa-dev list, but it was suggested
that I repost here.
I am creating a network client and wanted to include SOCKS5 proxy
support. I was excited to discover that NSStream has support for it
and I don't have to do much at all. But I can't seem to get it to
work. For purposes of unit testing, I've created a class of my own
called J3Stream that is just a wrapper around NSStream. It has this
method:
- (BOOL) setProperty:(id)value forKey:(NSString *)key
{
BOOL success = NO;
NSLog(@"Success: %d\nValue before set: %@\nKey: %@", success, value,
key);
success = [stream setProperty:value forKey:key];
NSLog(@"Success: %d\nValue after set: %@\nKey: %@",
success, [stream propertyForKey:key], key);
return success;
}
That gets called elsewhere in my code with a dictionary full of the
settings the NSStream documentation says I need to pass in. Here's a
copy of the log when I do that (passwords and the like have been
changed to protect the innocent):
----- BEGIN LOG -----
2005-01-07 14:15:05.130 Koan[16093] Success: 0
Value before set: <CFDictionary 0x344e40 [0xa01900e0]>{type =
immutable, count = 5, capacity = 5, pairs = (
0 : <CFString 0xa09f69a0 [0xa01900e0]>{contents =
"kCFStreamPropertySOCKSPassword"} = <CFString 0x344ca0
[0xa01900e0]>{contents = "password"}
1 : <CFString 0xa09f6978 [0xa01900e0]>{contents =
"kCFStreamPropertySOCKSVersion"} = <CFString 0xa09f69c8
[0xa01900e0]>{contents = "kCFStreamSocketSOCKSVersion5"}
3 : <CFString 0xa09f698c [0xa01900e0]>{contents =
"kCFStreamPropertySOCKSUser"} = <CFString 0x344c90
[0xa01900e0]>{contents = "samuel"}
4 : <CFString 0xa09f6950 [0xa01900e0]>{contents =
"kCFStreamPropertySOCKSProxyHost"} = <CFString 0x344c70
[0xa01900e0]>{contents = "elysium.arete.cc"}
8 : <CFString 0xa09f6964 [0xa01900e0]>{contents =
"kCFStreamPropertySOCKSProxyPort"} = <CFNumber 0x344da0
[0xa01900e0]>{value = +1080, type = kCFNumberSInt32Type}
)}
Key: kCFStreamPropertySOCKSProxy
2005-01-07 14:15:05.165 Koan[16093] Success: 1
Value after set: (null)
Key: kCFStreamPropertySOCKSProxy
----- END LOG -----
The source of my confusion is that NSStream -setProperty:forKey:
returns YES to indicate that the property was successfully set, yet it
clearly was not. This happens on both the input and output stream.
I'm creating these streams using NSStream
+getStreamsToHost:port:inputStream:outputStream:, but I ensure that the
property is set prior to the streams being opened. And I would expect
that it would return a status of NO if it couldn't set them.
Any ideas?
-- Samuel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden