Re: Telnet Networking Example
Re: Telnet Networking Example
- Subject: Re: Telnet Networking Example
- From: Eli Bach <email@hidden>
- Date: Thu, 23 Jul 2009 14:37:44 -0700
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