Caros Colegas
Quando tento realizar um a conexão através de socket, em um endereço valido ou um domino ele da a seguinte mensagem
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.net.SocketInputStream.read(SocketInputStream.java:90)
at br.com.rpinfo.Testes.TesteConect.main(TesteConect.java:31)
codigo escrito
try {
//Socket sckt = new Socket("10.11.0.81",10642);
Socket sckt = new Socket("dts.sigacred.com.br",10642);
if (sckt.isConnected()){
byte[] buff = new byte[4096];
DataOutputStream out = new DataOutputStream(sckt.getOutputStream());
InputStream in = sckt.getInputStream();
String cm = "1005332"
String VsTr= Func.chr(0)+Func.chr(3);
String mens = cm+VsTr;
out.writeBytes(mens);
out.flush();
int len = in.read(buff); //Recebendo o Conjunto de Bytes.
if (len < 2) {
System.out.println("Erro");
}
String msg = new String(buff,0, len,"ISO-8859-1"); //Criando a String e Setando CharSet
System.out.println("String Rec"+msg);
}else {
System.out.println("Nao Conectou");
}
}catch (SocketException ex){
ex.printStackTrace();
} catch (UnknownHostException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
Socket sckt = new Socket("dts.sigacred.com.br",10642);
ou Socket sckt = new Socket("200.195.137.89",10642);
Quando coloco o ip local funciona normalmente exemplo
Socket sckt = new Socket("10.11.0.81",10642);
Alguem pode me dar um help Obrigado.