Bonjour tout le monde,
le problème que j'ai c'est que lors de l'envoie du texte à partir de ma midlet vers le serveur cela marche très bien et le serveur reçoit le texte envoyé, mais une fois le serveur répond la midlet par l'envoi d'un fichier les deux se bloque, le serveur au niveau de outStream.write (b, 0, len) et la midlet à in.read (b).
Midlet
Server:
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 streamConnection =(StreamConnection)Connector.open(urlConn); // send coordinate to client OutputStream out = streamConnection.openOutputStream(); OutputStreamWriter pWriter= new OutputStreamWriter(out); pWriter.write("r"+coordonees); pWriter.flush(); // Response from client InputStream in = streamConnection.openInputStream(); FileConnection fc = (FileConnection)Connector.open("file:///C:/predefgallery/predefvideos/a2.3gp",Connector.READ_WRITE); fc.create(); OutputStream _out = fc.openOutputStream(); byte b[] = new byte[2048]; int len = 0; while ((len = in.read(b))!=-1){ _out.write(b,0,len); _out.flush(); } _out.close(); fc.close();
Merci d'avance.
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 StreamConnection connection = streamConnNotifier.acceptAndOpen(); InputStream inStream = connection.openInputStream(); bReader=new BufferedReader(new InputStreamReader(inStream)); String lineRead=bReader.readLine(); System.out.println("envoie de fichier"); OutputStream outStream = connection.openOutputStream(); FileInputStream fich = new FileInputStream("a.3gp"); byte b[] = new byte[2048]; int len=0; while((len = fich.read(b))!= -1){ System.out.println("suis la envoi"); outStream.write(b,0,len); outStream.flush(); System.out.println("suis la envoi après"); } fich.close();
Partager