How do I send telnet option codes?

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-12-26T16:48:12Z Indexed on 2010/12/26 16:53 UTC
Read the original article Hit count: 252

Filed under:
|
|

I've written a socket listener in Java that just sends some data to the client.

If I connect to the server using telnet, I want the server to send some telnet option codes. Do I just send these like normal messages?

Like, if I wanted the client to print "hello", I would do this:

PrintWriter out = new PrintWriter(clientSocket.getOutputStream());
out.print("hello");
out.flush();

But when I try to send option codes, the client just prints them. Eg, the IAC char (0xff) just gets printed as a strange y character when I do this:

PrintWriter out = new PrintWriter(clientSocket.getOutputStream());
out.print((char)0xff);
out.flush();

© Stack Overflow or respective owner

Related posts about java

Related posts about sockets