Re: Telnet Networking Example
Re: Telnet Networking Example
- Subject: Re: Telnet Networking Example
- From: DerNalia <email@hidden>
- Date: Thu, 23 Jul 2009 16:56:21 -0500
you're right, oStream isn't pointing to anything, but shouldn't
[NSStream getStreamsToHost:host
port:server_port
inputStream:&iStream
outputStream:&oStream];
take care of that?
I figured that having Garbage Collection on might be the problem, so I
moved all the open stream code to the same method that calls
getStreamsToHost, but I get the same result. So, just to see if the
Garbage Collector was pulling a fast one on me, I temporarily turned
it off. But I get the same result.

On Jul 23, 2009, at 4:37 PM, Eli Bach wrote:
On Jul 23, 2009, at 2:31 PM, DerNalia wrote:
Thanks all, for your help. I think I'm starting to understand what
is kind of going on. The example code helped a lot, however, now I
am not correctly receiving from the server:
This is what I'm using to send to the server:
if (oStream)
{
NSData * dataToSend = [command
dataUsingEncoding:NSUTF8StringEncoding];
int remainingToWrite = [dataToSend length];
void * marker = (void *)[dataToSend bytes];
while (0 < remainingToWrite) {
int actuallyWritten = 0;
actuallyWritten = [oStream write:marker
maxLength:remainingToWrite];
remainingToWrite -= actuallyWritten;
marker += actuallyWritten;
}
}
It was in the sample code, and I'm having a bit of trouble. What is
the test for oStream mean? what is it's purpose?
I changed if (oStream) to if(TRUE) and it went into an infinite loop.
oStream has already been opened, retained, delgate set to 'self'
and in runLoopMode. =/
but when I debug, it skips over the whole thing
Check the value of 'oStream' while stepping through.
The 'if (oStream)' part checks that the oStream pointer actually
points to something.
If you want to expand it, it would be
if (oStream != nil)
I think you will find that oStream is nil, which is why it is
skipping the code within the 'if' statement.
It is going into an infinite loop because since oStream is nil,
'[oStream write:marker maxLength:remainingToWrite];' always returns
0 (because you are sending the message to nil).
Eli
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden