Bonjour je commence tout juste dans le domaine de l'envoie/reception de fichier xml. j'ai un petit soucis, ça ne réagit pas du tout voila mon code source le plus simplifié :
Serveur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
public class HTTPServer{
 
    public static final int HTTP_PORT=8080;
 
 
    public void run(){
        try {
            ServerSocket listen = new ServerSocket(1314);
            while(true) {
                Socket client = listen.accept();
                ClientConnection cc = new ClientConnection(client);
            }
        }
        catch(Exception e) {
            Logger.global.severe("Exception: " + e.getMessage());
        }
    }
 
    public static void main(String[] args){
        HTTPServer s = new HTTPServer();
        s.run();
        }
    }
la classe ClientConnection :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
 class ClientConnection extends Thread{
     Socket sock;
     BufferedReader in;
     DataOutputStream out;
 
     public ClientConnection(Socket s){
         sock = s;
         try {
             in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
             out = new DataOutputStream(sock.getOutputStream());
         } catch (IOException e) {}
         this.start();
     }
 
     public void run(){
         try {
             shipDocument(out);
         } catch (Exception e) {}
     }
 
     public static void shipDocument(DataOutputStream out) throws Exception {
         try {
             out.writeBytes("HTTP/1.0 200 OK\r\n");
             out.flush();
         }finally {
            out.close();
         }
 
     }
 }
une fois le serveur lancé je lance une autre classe client :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
public class ClientWap extends Thread{
 
     public static void main(String[] args) throws IOException {
       ClientWap ex= new ClientWap();
    }
    public ClientWap() throws IOException {
        this.run();
    }
    public void run(){
        try {
            Socket ClientSocket = new Socket("localhost", 1314);
            BufferedReader input = new BufferedReader(new InputStreamReader(ClientSocket.getInputStream()));
            DataOutputStream output = new DataOutputStream(ClientSocket.getOutputStream());
            receiveconfirmation(input);
            ClientSocket.close();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    public static void receiveconfirmation(BufferedReader input) throws Exception {
        try {
            do{
                sleep(5000);
                System.out.println("has slept 5 s");
            }while(input.ready()==false);
 
            String Line = null;
            do {
                Line = input.readLine();
                if (Line != null) {
                    System.out.println("Line : " + Line);
                }
            } while (Line != null);
            input.close();
        }
        catch (Exception e) {
 
        }
        finally {
            input.close();
        }
    }
}
je ne receptionne rien c'est bizarre. quequn peut m'aider, ce serait gentil