+- (BOOL)checkForServerAtHost:(NSString *)host
+{
+ NSData *fullPass = [[NSUserDefaults standardUserDefaults] dataForKey:@"connectPassword"];
+ unsigned char buffer;
+ NSConnection *testConnection;
+ NSSocketPort *testPort;
+ NetworkObject *tempProxy;
+ ITDebugLog(@"Checking for shared remote at %@.", host);
+ if (fullPass) {
+ [fullPass getBytes:&buffer range:NSMakeRange(6, 4)];
+ [clientPass release];
+ clientPass = [[NSData alloc] initWithBytes:&buffer length:strlen(&buffer)];
+ } else {
+ clientPass = nil;
+ }
+
+ NS_DURING
+ testPort = [[NSSocketPort alloc] initRemoteWithTCPPort:SERVER_PORT
+ host:host];
+ testConnection = [[NSConnection connectionWithReceivePort:nil sendPort:testPort] retain];
+ [testConnection setReplyTimeout:2];
+ tempProxy = (NetworkObject *)[testConnection rootProxy];
+ [tempProxy serverName];
+ NS_HANDLER
+ ITDebugLog(@"Connection to host failed: %@", host);
+ [testConnection release];
+ [testPort release];
+ return NO;
+ NS_ENDHANDLER
+
+ if (!clientProxy) {
+ ITDebugLog(@"Null proxy! Couldn't connect!");
+ [testConnection release];
+ [testPort release];
+ return NO;
+ }
+ [testConnection release];
+ [testPort release];
+ return YES;
+}
+