私は既存のサーバーアプリケーションのクライアントであるiPhoneアプリを持っています。NSHostは非常に長い時間がかかります
次のコードを使用して接続していますが、このコードは正常に動作しています。今日私はプロジェクトの作業を開始し、何か変わったことが起こっています。
「接続」をクリックすると、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];
[email protected]"Connection Error! Please check connection settings.";
}
}else{
[self resetConnectionAndScreen];
[email protected]"Connection Error! Please check connection settings.";
}
}
//をいくつかの光を当てることができ、私も今、これらの警告を取得しています。** ... WTH! :)
- 警告:いいえ '+ hostWithAddress:':一致するメソッドのシグネチャなし
- 警告(メッセージ:この方法は、
- 警告が見つかりませ '+ hostWithName:' メソッドは、
- 警告が見つかりません:「NSStreamポート:InputStreamの:のOutputStream:+ getStreamsToHost 'に応答しないこと ''
'NSHost'も' getStreamstoHostどちらを使用してネットワーク化する別の方法です... 'iPhone上に存在します – user102008