slt a tous le monde
j travaille sur un programme sur le réseaus,ou mon application dans chaque poste du reseau faite un calcle si trouve un resultat (certains conditions vérifier)envoté un message vers les autre poste ,j veux réaliser avec l'utilisation des socket ,le serveur marche mais le client ne marche plus voici le code du client et le code du serveur:
import java.net.*;
import java.io.*;
public class serveur extends Thread {
public static final int PORT =8080;
private Socket socket;
private BufferedReader in;
private PrintWriter out ;
public serveur (Socket s)throws IOException {
socket=s;
in=new BufferedReader ( new InputStreamReader(socket.getInputStream()));
out =new PrintWriter (new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
start();
}
public void run(){
try{
while (true){
String str =in.readLine();//str le resulta de notre fonction de type string q'on veux envoyé au autre postes
if(str.equals ("END"))break;
System.out.println("Echowing:"+str);
out.println(str);
}
System.out.println("closing...");
}catch (IOException e){
System.err.println("IOException");
}finally{
try{
socket.close();
}catch (IOException e){
System.err.println("Socket not closed ");
}
}
}
}
class Multiserveur {
public static final int PORT =8080;
public static void main(String []args )throws IOException {
ServerSocket s=new ServerSocket(PORT);
System.out.println("server started");
try{
while (true){
Socket socket=s.accept();//attends message a cote du client
try{
new serveur (socket);
}catch(IOException e){
socket.close();
}
}
}finally{
s.close();
}
}
}
mais le client m'affiche une exeption est qu'il ne trouve pas variable PORT voici le code:
import java.net.*;
import java.io.*;
public class client {
public static void main (String []args){
InetAddress addr=InetAddress.getByName(this.serveurchat);
System.out.println("addr="+addr);
Socket socket =new Socket (addr, serveur.PORT);
try {System.out.println("socket= "+socket);
BufferedReader in=new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter out =new PrintWriter (new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
for(int i=0;i<10;i++){
out.println("howday"+i);
String str=in.readLine ();
System.out.println(str);
}
out.println("END");
}finally{
System.out.println("closing....");
socket.close();
}
}
}
aider moi SVPj'attends vos repense merci d'avance