Aqui el codigo
Código:
class ServicioB extends Thread { static DatagramSocket ss; public ServicioB(DatagramSocket s) {ss=s;} public void run() { try { while(true){ byte buffer[] =new byte[1000]; DatagramPacket p =new DatagramPacket(buffer,1000); ss.receive(p); System.out.println(p.getData()); DatagramPacket dp= new DatagramPacket(buffer,p.getLength(), InetAddress.getByName("localhost"),8877); ss.send(dp); } }catch(Exception e) {} }
Código:
Como cliente uso netcat conectandome a localhost al puero 8877import java.net.*; import java.io.*; class Multiprotocolo { public static void main(String args[])throws IOException { DatagramSocket dsB =new DatagramSocket(8877); new ServicioB(dsB).start(); } }
Que esta mal?
Saludos y gracias de antemano
}