• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Weird socket/stream behaviour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Weird socket/stream behaviour


  • Subject: Weird socket/stream behaviour
  • From: Kenny Millar <email@hidden>
  • Date: Thu, 5 Jan 2006 21:05:40 +0000

Hi again.

I have another issue with my new app that I hope someone can help me with. (I'm new to cocoa so I'm pleased to have gotten even this far!)
The scene is this, I have a cocoa app which connects to a service running on windows servers. (Windows Server 2003).


I have the service running on half a dozen or so servers. They are all the same, on the same subnet, with the same software on them all.

My client (cocoa) app connects to just one server at a time.

The weird behaviour is that it can connect to about half of the servers and communicate back/forth with them no trouble at all.
On the other half of the machines, I get a NSStreamEventErrorOccurred in my stream handleEvent: method immediately that I attempt the connection.


When I query the stream error using :-
	NSError* er = [stream streamError];
	NSLog(@"Stream Event Error x, %@",stream,[stream streamError]);

Produces :-
... NSError "Error NSUnknownErrorDomain 7" Domain=NSUnknownErrorDomain Code=7


But, if I use 'telnet' from the same mac to one of the 'non working' windows servers, then I can manually chat with the server with no trouble at all. This suggests to me that the problem lies in my cocoa connection code. It has to be my cocoa code since telnet works.

One final point, it's always the same machines that work and the same ones that don't work. (But telnet works to/from all machines with no problems.)

I've posted my 'connect to server' code below.

Thanks for any help...
-KennyM.


The connect code:-

- (IBAction)connectServer:(id)sender
{
int nPort=41000;
NSString *serverAddr = [serversComboBox stringValue];

// if no server, then nothing to do.
if ([serverAddr length] == 0)
{
[infoText setString:@"No server address supplied.\n"];
NSRunAlertPanel(@"Can't connect",@"No server address supplied.\nYou need to supply the address of a SCOPE Server.",@"OK",nil,nil);
return;
}

if ([serverPort intValue] != 0)
nPort = [serverPort intValue];


// Do the user feedback
[connectSpinner startAnimation:self];
[disconBut setEnabled:TRUE];
[connectBut setEnabled:FALSE];

NSString *str = [NSString stringWithFormat:@"Connecting to: %@:%d \n",serverAddr,nPort];
[infoText insertText:str];

// start the timeout timer
tickCounts=0;
timer = [[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerTick:)
userInfo:nil repeats:YES] retain];
// reset the boolean
bConnected = FALSE;

//attempt the connection
[NSStream getStreamsToHost:[NSHost hostWithName:serverAddr] port: 41000 inputStream:&iStream outputStream:&oStream];
if((!iStream) || (!oStream))
{
[self disconnectServer:nil];
[infoText insertText:@"Could not connect.\n"];
NSRunAlertPanel(@"Can't connect",@"Could not connect to the server.",@"OK",nil,nil);
return;
}

[iStream retain];
[oStream retain];


	NSLog(@"iStream:x, oStream:x\n",iStream,oStream);

	[iStream setDelegate:self];
	[oStream setDelegate:self];

[iStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[oStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];


	[iStream open];
	[oStream open];

}


_______________________________________________ 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
  • Prev by Date: Horizontally scrolling NSTextView in IB
  • Next by Date: Re: Horizontally scrolling NSTextView in IB
  • Previous by thread: Weird socket/stream behaviour
  • Next by thread: inspector
  • Index(es):
    • Date
    • Thread