Java - Objeto URL y telnet

 
Vista:

Objeto URL y telnet

Publicado por Antonio (1 intervención) el 11/04/2002 08:26:43
Quiero usar un objeto URL con el protocolo telnet, pero me dice :
java.net.MalformedURLException: unknown protocol: telnet.
Creo que hace falta tener una implementacion del protocolo en la MV, pero no se donde buscar el modulo. ¿Alquien sabe como hacerlo?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Objeto URL y telnet

Publicado por Carlos Pinto (1 intervención) el 04/08/2007 18:40:48
este código logra establecer una conexion telnet con un servidor.
me falta mejorarlo. Todavía es muy ineficiente.
si le haces algunas mejoras por favor envialo a
[email protected]
Espero que te sirva...

import java.io.*;
import java.net.*;
import java.util.*;

public class TelnetInputStream extends InputStream
{
private static DataInputStream input;
private static DataOutputStream output;
private int width, height;
private String terminal;

byte IAC=0;
byte SB=0;
// used for replies
private final byte[] reply = { IAC, (byte) 0, (byte) 0 };
char c;

public void ESPERAR()throws IOException, InterruptedException{

Thread.sleep(10);
}

public TelnetInputStream(InputStream inInput, OutputStream inOutput)
{

try{

String linea=null;

int N,i;
while(true){

try{ESPERAR();}catch (InterruptedException e){e.printStackTrace();}

System.out.print('*');
N=inInput.available();
if(N!=0){
System.out.print('\n');
for(i=0;i<N;i++){
c=(char)inInput.read();
System.out.print(c);
}


try{BufferedReader br = new BufferedReader(new InputStreamReader(System.in));linea = br.readLine();}catch(Exception e){e.printStackTrace();}
inOutput.write((linea + "\n").getBytes());
inOutput.flush();

}


}

}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}

}

public static void main(String[] arg)
{
try
{
Socket s = new Socket("localhost",5000);
System.out.println(s);
input = new DataInputStream(s.getInputStream());
output = new DataOutputStream(s.getOutputStream());
TelnetInputStream dir = new TelnetInputStream(input, output);

}
catch(IOException e)
{
System.out.println("Error "+e);
}
}
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar