Re: Trying to use NSStream
Re: Trying to use NSStream
- Subject: Re: Trying to use NSStream
- From: Development <email@hidden>
- Date: Sat, 12 Jan 2008 18:16:04 -0700
Ok... Did any one else get the memo that the EOL character had been
changed to the char(10).
Every document I've read and all information I have seen tells me that
I suffix every line I send to a server with either \n or \r or \n\r or
some other such combination. Either way... I have never had to do
sendString = [NSString stringWithFormat:@"%@\r%c",aString,10]; I do
not know what Char 10 is however I am assuming it is an EOL or EOF
character? Either way this seems to be unique to NSStream as other
tools I've used require only the \r. When using NSStream it seems that
for anything but http it requires both a \r and character 10. (\n
didn't work and neither did the character by itself.)
I discovered that with every server, the final character of each
welcome message was ascii character 10 preceded by character 13 so I
tried it and it worked.
I suppose I'm hoping some one can explain this to me. Even though it
is working I do not understand why and would be grateful if some one
could clarify.
On Jan 12, 2008, at 4:24 PM, Development wrote:
Hmm.. I am quite lost here and cannot seem to find any information.
I am trying to use NSStream to connect to and communicate with a
mail server. The connection actually seems ok and I get the +OK
hello message from the server then all further communications fail.
When I try to send a request to the serve I get no data back...
However I have no trouble at all communicating with http servers.
Any way this is my write code:
- (IBAction)sendText:(NSString*)stringToSend
{
NSLog(@"StringToSend %@",stringToSend);
[rawData insertText:[NSString stringWithFormat:@"\n
%@",stringToSend]];
[textField setStringValue:@""];
NSData * dataToSend = [stringToSend
dataUsingEncoding:NSISOLatin1StringEncoding];
if (ostream) {
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;
}
}
}
After I send a block of data and get nothing back. The input stream
has no data available and the event sent to the controller is
NSStreamEventHasSpaceAvailable along with the outputstream for the
stream variable. I have made sure that I append \n to the end of
each string I send, I have also tried \r instead but nothing seems
to help. Any ideas?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden