Created
March 14, 2016 22:38
-
-
Save maleficarum/3e6a6415fa72ebb414bb to your computer and use it in GitHub Desktop.
Telnet Java 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Socket socket = new Socket("192.168.1.1", 23); | |
socket.setKeepAlive(true); | |
BufferedReader r = new BufferedReader(new InputStreamReader(socket.getInputStream())); | |
PrintWriter w = new PrintWriter(socket.getOutputStream(),true); | |
int c=0; | |
while ((c = r.read()) != -1) | |
System.out.print((char)c); | |
w.print("1234\r\n"); // also tried simply \n or \r | |
//w.flush(); | |
//Thread.sleep(1000); | |
while ((c = r.read()) != -1) | |
System.out.print((char)c); | |
w.print("1234\r\n"); | |
//Thread.sleep(1000); | |
while ((c = r.read()) != -1) | |
System.out.print((char)c); | |
socket.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment