Je suis en train de créer un client serveur, tt se passe bien sauf l'envoi des messages, quand je clique sur envoyer, rien ne se passe, si quelqu'un peut m'aider svp. voici le code source du serveur, puis du client
public Serverr (Socket s) throws IOException {
socket= s;
in= new BufferedReader( new InputStreamReader( socket.getInputStream()));
out= new PrintWriter( new BufferedWriter( new OutputStreamWriter( socket.getOutputStream())), true);
start();
}
}
//la classe principale
public class Server {
Shell shell;
Image image;
ServerSocket s;
BufferedReader in;
Text msgRecu;
Button start;
Socket socket;
Button close;
boolean isActive;
String line;
// la méthode run
public void run () {
try {
while (true) {
String line= in.readLine();
if (line.equals("END")) break;
System.out.println(line);
}
System.out.println("Closing...");
}catch (IOException e) {
System.err.println("IOException");
} finally {
try {
socket.close();
} catch (IOException e) {
System.out.println("Socket not closed");
}
}
}
//le constructeur
public Server () throws IOException {
Display display= new Display();
shell= new Shell(display);
shell.setSize(400,400);
msgRecu= new Text(shell, SWT.CENTER);
msgRecu.setBackground(new Color (display, 255,255,255));
msgRecu.setBounds(60, 20, 300, 275);
start= new Button(shell, SWT.CENTER);
start.setBounds(100, 300, 100, 55);
start.setText("Start");
close= new Button(shell, SWT.CENTER);
close.setBounds(220, 300, 100, 55);
close.setText("Close");
class Starter extends Thread{
public void run(){
try{
s= new ServerSocket(6000);
while(isActive){
new Handler(s.accept()).start();
}
}
catch(IOException e){}
}
}
Listener listener2= new Listener() {
public void handleEvent (Event event) {
new Starter().start();
}
};
start.addListener(SWT.Selection, listener2);
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
static final int PORT = 8080;
//méthode main
public static void main(String[] args)
throws IOException {
new Server();
ServerSocket s= new ServerSocket(PORT);
System.out.println("Server Started");
try {
while(true) {
// Blocks until a connection occurs:
Socket socket = s.accept();
try {
new Serverr(socket);
} catch(IOException e) {
// If it fails, close the socket,
// otherwise the thread will close it:
socket.close();
}
}
} finally {
s.close();
}
}
}