-
telnet echo nagotiations
I know this is not much of a programming question, but I had no other place to go to...
I alittle help with telnet echo nagotiations.
you see, I'm writing a server, and I know that the server needs to send the 0xff 0xfb 0x01 to let the client know that his with remote echo the sent to him data.
and the client needs to send back: 0xff 0xfd 0x01
The thing is that, when server sends this 3 bytes to the client, the client does understand that this bytes are part of the nagotiation.
what am I doing wrong?
Thanks alot.
-
Can we assume you've read the relevant RFC's regarding telnet?
> what am I doing wrong?
Not posting some code?
-
i was unable to find the right rfc, because there are more than one on the telnet protocol.
but I did sit with a sniffer and looked at what the telnet server is sending, and that was 0xff 0xfb 0x01, and the sniffer even identified it as a "the server will echo" and the client answers: "do echo" which is: 0xff 0xfd 0x01
if you have the right rfc, I would love to read it.
-
Check the telnet client you are using as well. I have 5 different telnet clients that I use to test my socket programming, and I have 5 different variations on behavior. In fact, only one of the telnet clients by default actually deals with OOB data when the connection is established (I think it's TTerm Pro, I also use Nifty Telnet, IVT Freeware Telnet, windows telnet and cygwin's telnet).
I never really dived into the telnet RFC's much because the behavior I am looking for is in a MUD (line input, nothing fancy, any problems just drop connection and re-connect), so 4 of my 5 telnet clients made me happy, and the 5th made me add in a response to ignore the intial OOB handshake (resulting in about a 2 second delay for clients that don't initially send the handshake data).
Hope this helps.
-
the thing is that i have 2 clients:
the one is the windows 98's client, and putty client.
the thing is, that for the windows' one i need to send back the input from the client so i'll see in the client what i'm typing.
but with putty, because i didn't do any negotiations it activates a local echo, so when my server sends back the input, in the putty client i see double what i type in it.
I want to do the hand shake (the negotiation), but how?
because I guess what I saw in the sniffer is wrong or something, and I can just send() back what i recv() from the client...
-
The way I learned what each of my telnet clients was doing was to write a very simple server. Once it was connected to by a client, it would simply echo the character and the ASCII code of that character to the standard output (cout). Connect to server, watch for output, start typing in telnet client, watch output. You could also have your telnet client send the OOB data and watch in the server console what bytes are actually being sent across.
This could be extended by giving the server marginally more function and allowing it to type back to the client. For example, if you type 'A' in the server window, it will send the "0xff 0xfb 0x01" to the telnet client, and then you can see what (if anything) the telnet client is sending back to the server in response. (This way you don't have to keep re-connecting to the server just to have it send the bytes to the client again unless your telnet client won't change behavior without re-connecting itself).
Beej's guide has a relatively simple server that you could easily modify for this purpose (in fact, the server as written will already just echo the text back, all you would need to add would be the ASCII #'s in the output). Do a search for "Beej" and you should find it easily.
Alternatively, you could dig deeper into the telnet RFC's. (I'm so glad I don't care what size the client's terminal is going to be or whether it is echoing local text, etc. MUDs don't care about that stuff, just send raw lines of text! Muhahaha!)
-
i checked with the sniffer again, and this is what i got:
the server sends the client an IAC WILL ECHO (0xff 0xfb 0x01)
and the client sends back an IAC DO ECHO (0xff 0xfd 0x01)
the funny thing is, that some servers send the will echo, and others send do echo...
I don't know what to do, how can I let the client know that I am going to remote echo, so the client won't need to auto echo locally...
btw, what is this MUD and OOB?
Thanks again.
-
Well, a MUD is a multi-user-dungeon (a text based adventure game played in real-time via a telnet connection). There are tons of 'em out there, and I'm writing yet another one.
OOB stands for Out-Of-Band data which is what the IAC Do Echo stuff is - out of the normal realm of what data is being transferred between the client and the server.
Normally the client is typing away, interacting with the server in whatever capacity the server is set up for (a unix shell, for example) and the server is responding appropriately. But say the telnet client re-sizes the window. In order for the client to inform the server of the new window size, it has to send OOB data, which is the special characters the telnet RFC defines. When the server sees those characters, it says, "Hey, the telnet program just resized it's window, I need to adjust how I'm sending text to display it appropriately". Not all telnet sessions need to deal with all types of OOB data.
You should read up more on the telnet RFC's (do a google search just for "telnet RFC" and you'll get alot of hits).
-
well rfc857 does talk about the echo negotiation... but it doesn't say what the server and the client suppost to send.
also, this negotiation can take place in the middle and not only at the beginning (if I undertood it right), so what tells the other side, if it's just data or the negotiation?