It might be helpful to take a step back first.
telnet may not be the best protocol to try implementing first, since there's some preliminary option negotiation as part of the telnet protocol. If you're using tcpdump, you might try something like "tcpdump -n -i -s 0 -X" to capture complete packets (-s 0) and view them as both hexadecimal and ascii (-X). If you try that, you might see the option negotiation happening within the body of the packets.
You might also want to look at using netcat (nc). That will let you establish raw connections from a shell, and if you run it in listening mode, your code will probably connect and you'll see the output.
You can also test with nc as a client to verify what you're doing in code. For instance, this is what I get when using nc to do a raw tcp connection to my telnet server:
Which is pretty different from the server greeting and username/password prompt you'd see from a telnet client.
telnet may not be the best protocol to try implementing first, since there's some preliminary option negotiation as part of the telnet protocol. If you're using tcpdump, you might try something like "tcpdump -n -i -s 0 -X" to capture complete packets (-s 0) and view them as both hexadecimal and ascii (-X). If you try that, you might see the option negotiation happening within the body of the packets.
You might also want to look at using netcat (nc). That will let you establish raw connections from a shell, and if you run it in listening mode, your code will probably connect and you'll see the output.
You can also test with nc as a client to verify what you're doing in code. For instance, this is what I get when using nc to do a raw tcp connection to my telnet server:
Code:
id 11:49:44 ~> nc localhost 23
���� ��#��'mactjaap
test123
^C