Did [NSStream getStreamsToHost:...] change its behavior lately?
Did [NSStream getStreamsToHost:...] change its behavior lately?
- Subject: Did [NSStream getStreamsToHost:...] change its behavior lately?
- From: Andrei Tchijov <email@hidden>
- Date: Fri, 7 Jul 2006 16:54:33 -0400
For quite a long time now, following code was working just fine:
...
NSHost *host = [NSHost hostWithName: @"localhost" ];
[NSStream getStreamsToHost:host port: 1313 inputStream:&_iStream
outputStream:&_oStream];
if( _iStream == nil || _oStream == nil ) {
...
} else {
[_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];
}
...
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {
...
}
...
Today it stop working (today I have noticed. it is possible that it
stop working after I have installed 10.4.7). After some
investigation I came to conclusion that for unknown reason this code
trying to connect to "::1" (IP v 6) instead of "127.0.0.1" (IP v
4 ). While snooping around, I have noticed that "telnet" start doing
the same thing:
sh-2.05b# telnet localhost 1313
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Is it result of 10.4.7? Is it possible to force IPv4? I was able to
"fix" the problem by replacing "hostWithName:" with "hostWithAddress:"
...
NSHost *host = [NSHost hostWithAddress: @"127.0.0.1" ];
...
Is it possible to "simulate" telnet-like behavior - if it fails with
IPv6 to make it try IPv4 (to detect that NSStreamEventErrorOccurred
is due to attempt to talk to "::1" and ignore it? )?
You comments will be greatly appreciated.
Andrei Tchijov
_______________________________________________
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