Note that there are some explanatory texts on larger screens.

plurals
  1. POTelnet IAC commands (NSStream socket)
    primarykey
    data
    text
    <p>I've made a <code>NSStream</code> socket to connect to a telnet server. Actually, it can connect fine to the server; I got an <code>inputStream</code> with the "first words" of the server, but I don't understand it. I'm looking for some explanations about the telnet IAC commands.</p> <p>Here is my code to receive from the server:</p> <pre><code> case NSStreamEventHasBytesAvailable: if (theStream == inputStream) { uint8_t buffer[1024]; int len; while ([inputStream hasBytesAvailable]) { len = [inputStream read:buffer maxLength:sizeof(buffer)]; if (len &gt; 0) { NSString * serverSaid = [[NSString alloc] initWithBytes:buffer length:len encoding:NSASCIIStringEncoding]; if (nil != serverSaid) { NSLog(@"The server said: %@", serverSaid); [connectLog insertText:serverSaid]; [connectLog insertText:@"\r"]; } } } } break; </code></pre> <p>It is based on the EventHasBytesAvailable. It is working fine (got the hello from server with the login prompt).</p> <p>Now, to send to the server, I do this:</p> <pre><code>NSString * theMsg = [NSString stringWithFormat:@"root"]; NSData * msgToSend = [[NSData alloc] initWithData:[theMsg dataUsingEncoding:NSUTF8StringEncoding]]; [outputStream write:[msgToSend bytes] maxLength:[msgToSend length]]; </code></pre> <p>I scripted the output on a button, to see what happen when I use the outputstream: EventHasBytesAvailable catch my output has input... The server is telling me what I told him!</p> <p>Can someone explain to me the IAC commands and/or how to to proceed to login on the server and send commands?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload