既存のサーバー アプリケーションのクライアントである iPhone アプリがあります。
次のコードを使用して接続していますが、このコードは正常に機能していました。今日、私はプロジェクトの作業を開始しましたが、奇妙なことが起こっています。
[接続] をクリックすると、NSHost が解決してホストに接続するのに約 30 ~ 45 秒かかります。接続が確立されると、データ転送速度は通常の高速になります。
元のクライアント ソフトウェア (PC アプリケーション) を同じサーバーに接続しており、接続はすぐに処理されます。
おそらく、誰かがこの主題に光を当てることができます...
-(IBAction)tryConnection{
[self showLogoffButtons];
iPhone_PNPAppDelegate *mainDelegate = (iPhone_PNPAppDelegate *)[[UIApplication sharedApplication] delegate];
settings=mainDelegate.settings;
[activityindicator startAnimating];
sendState=0;
NSHost* host;
//30-45 second pause happens here (since I am using an IP Address)
host = [NSHost hostWithAddress:settings.masterLocation];
//NSHost returns (eventually) with the correct connection.
if (!host) {
host = [NSHost hostWithName:settings.masterLocation];
}
if( host ) {
[NSStream getStreamsToHost:host port:[settings.masterPort intValue] inputStream:&iStream outputStream:&oStream] ;
if( nil != iStream && nil != 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];
}else{
[self resetConnectionAndScreen];
self.navigationItem.prompt=@"Connection Error! Please check connection settings.";
}
}else{
[self resetConnectionAndScreen];
self.navigationItem.prompt=@"Connection Error! Please check connection settings.";
}
}
//また、これらの警告が表示されるようになりました.**.. wth?! :)
- 警告: '+hostWithAddress:' メソッドが見つかりません
- 警告: (一致するメソッド署名のないメッセージ
- 警告: '+hostWithName:' メソッドが見つかりません
- 警告: 'NSStream' は '+getStreamsToHost:port:inputStream:outputStream:' に応答しない可能性があります