Hello
I just started network programming in java, and I took my first sockets (client / server) via a UDP protocol. But that does not work. So, may be you can help me out, here is my code.
Code:
Public class serveurUDP {
static int sz = 1024;
static byte[] buff = new byte[sz];
static int pt = 9332;
Public static void hand(String[] args)throws Exception {
DatagramSocket sc = new DatagramSocket(pt);
String give = "";
String message = "";
sz = 0;
System.out.System.out.println("Server Initialized");
while(true) {
DatagramPacket packet = new DatagramPacket(stamp, stamp.length);
sc.receive(Package);
System.out.System.out.println(package received from:+ Package.getAddress());
sz = packet.getLength();
gives = new String(package.getData(),0, Size);
message = "hello"+ yields;
System.out.System.out.println("Data that will be sent are:+ Message);
DatagramPacket send = new DatagramPacket(message.getBytes(), Message.length(), Pack.getAddress(), Pack.getPort());
sc.Send(sends);
}
}
}
Bookmarks