voici l'implementation de mon code, je sais que c'est pas clean mais c'est que le debut
[php]/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Bot;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author zouhairhajji
*/
public class Client extends Thread{
private boolean running;
private static int PORT = 5555;
private static String HOST = "80.239.173.166";
private Socket socket;
private DataOutputStream out = null;
private DataInputStream in = null;
public boolean connect(){
try {
this.socket = new Socket("80.239.173.166", 5555);
out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
in = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
this.running = true;
return true;
} catch (Exception e) {
return false;
}
}
public boolean sendString(String message) throws IOException{
String endLine = "\r\n";
this.out.writeUTF(message+ endLine);
this.out.flush();
return true;
}
public String readData() throws IOException{
byte[] bytes = new byte[1024];
in.read(bytes);
return new String(bytes);
}
@Override
public void run() {
while(running){
System.out.println("Attente d'un nouveau message");
try {
System.out.println(readData());
sendString("1.29.1");
sendString("compte\n#md5(pass)");
sendString("Af");
} catch (IOException ex) {
Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
System.exit(0);
}
}
}
}
[/php]