Great that you are communicating over the socket!
First... As to the data you are receiving - telnet is an intelligent communication protocol. The server expects a connection from a telnet aware client by default. When the connection is established, the server sends out a negotiation sequence to inform the client of the server capabilities and communication parameters to be used.
The "\xff\xfd\x01\xff\xfd\x1f\xff\xfd!\xff\xfb\x01\xff\xfb\x03" sequence is the telnet negotiation from the server to the client. If the client does not respond with an answering sequence, the telnet server will use its defaults. After the telnet negotiation information, the actual ASCII text communication.
It appears you are dumping the "raw" hex representation of the ASCII data.
'\r' - is a carriage return character => move to the beginning of the line for output
'\n' - is a new line character => move to the next line
So, you are receiving the ASCII sequence for
After "Password:" you are receiving '\r\r\n' to move to the next line. This is not the usual login sequence. I would expect a user prompt followed by the password prompt.
You are seeing this as raw character data on the screen because the line 'rcvData' dumps the variable content without formatting. If you want it interpreted as ASCII characters, you can use:
The telnet negotiation information will display as "garbage" characters, but you will see the ASCII strings as you expect.
If you want to fully understand the telnet protocol, you can read the relevant RFC 854 Telnet Protocol Specification
and others for details about the options.
From the protocol, the server sequence you are receiving is interpreted as:
Code: Select all
255,253,1 DO ECHO
255,253,31 DO NAWS (Negotiate About Window Size)
255,253,33 DO TOGGLE FLOW CONTROL
255,251,1 WILL ECHO
255,251,3 WILL SUPPRESS GO AHEAD
If you ignore the initial server negotiation and you can use simple ASCII communication in most cases.