Bonjour,
J'ai crée un applet UdpClient qui fonctionne correctement lorsque je le lance à partir de java (dans fenetre DOS, commande Java UdpClient)
Lorsque je place cet apllet dans une page HTML, il ne fonctionne plus. Quelqu'un peut il m'in idiquer la cause de ce problème, et comment y remédier
Merci d'avance
cai dessous l'applet:
import java.net.*;
import java.io.*;
/**
* Client UDP
* Il faut d'abord lancer le serveur et ensuite le client
*/
public class UdpClient{
public static void main(String[] args) throws IOException {
//Création socket
InetAddress address = InetAddress.getByName("monIP");
int port = monPort;
//Envoi d'un datagramme au groupe
String ch = "Le message à envoyer";
int chl = ch.length;
byte[] message = new byte[chl];
ch . getBytes(0,chl,message,0);
DatagramPacket p = new DatagramPacket(message, chl, address, port);
datagramSocket s = new DatagramSocket();
s.send(p);
//Fermeture du socket
s.close();
System.exit(0);
}
}
Page html
<HTML>
<HEAD>
<TITLE>Socket</TITLE>
</HEAD>
<BODY>
<h1>Socket</h1>
<hr>
<applet NAME="UdpClient" codebase="." code="UdpClient.class" width=170 height=150 >
alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason."
Your browser is completely ignoring the <APPLET> tag!
</applet>
<hr>
</BODY>
</HTML>
dalton