Programation des socket

Résolu
taznakhte Messages postés 63 Date d'inscription   Statut Membre Dernière intervention   -  
taznakhte Messages postés 63 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
azul
j'ai un problème lors de l'exécution des programmes (en java), des socket entre le clavier et le moniteur,suivant :
du client (clavier):

import java.io.*;
import java.net.*;
class clientTCP{

public static void main(String argv[]) throws Exception
{
String phrase;
String phraseModifiee;

BufferedReader entreeDepuisUtilisateur = new BufferedReader(new InputStreamReader(System.in));

Socket socketClient = new Socket("localhost", 4567);


PrintWriter sortieVersServeur = new PrintWriter(socketClient.getOutputStream(),true);
BufferedReader entreeDepuisServeur = new BufferedReader(new InputStreamReader(socketClient.getInputStream()));

phrase = entreeDepuisUtilisateur.readLine();

sortieVersServeur.println(phrase);


phraseModifiee = entreeDepuisServeur.readLine();

System.out.println("RECU DU SERVEUR: " + phraseModifiee);

entreeDepuisUtilisateur.close();
entreeDepuisServeur.close();
sortieVersServeur.close();
socketClient.close();

}
}
et pour le serveur (monoteur):
import java.io.*;
import java.net.*;

class serveurTCP {

public static void main(String argv[]) throws Exception
{
String phraseClient;
String phraseMajuscule;

ServerSocket socketEcoute = new ServerSocket(4567);

while(true) { // boucle infinie

Socket socketConnexion = socketEcoute.accept();

BufferedReader entreeDepuisClient =
new BufferedReader(new
InputStreamReader(socketConnexion.getInputStream()));
PrintWriter sortieVersClient =
new PrintWriter(socketConnexion.getOutputStream(),true);


phraseClient = entreeDepuisClient.readLine();

phraseMajuscule = phraseClient.toUpperCase();

sortieVersClient.println(phraseMajuscule);

} // fin boucle (repartir et attendre une nouvelle connexion)
}
}
on utilisant le protocole TCP
merci (tanmmirte)!!!!!!!!!!!

2 réponses

Nabla's Messages postés 18203 Date d'inscription   Statut Contributeur Dernière intervention   3 193
 
tu ferai bien de préciser un peu ce que tu entends par "problèmes"
0
taznakhte Messages postés 63 Date d'inscription   Statut Membre Dernière intervention   1
 
Bonjour:
le problème lors de l'exécution sous eclipse
tanmmirte (merci).
0