Advertisement
Guest User

Creation serveur et envois identite

a guest
May 29th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1.  public void creationServeur() throws IOException{
  2.        
  3.         System.out.println("Je vais cree le serveur");
  4.         FeuillePersoMJ.serveurFJ1 = new ServerSocket(1601, 10); // Creation ServeurSocket pour les échanges d'Object FichePerso 1
  5.        
  6.     }
  7.  
  8. public static void envoisIdentite() throws IOException{
  9.    
  10.         int portSocketServeurFJ1 = 1601; // Création d'un numéro de port pour les ServeurSocket
  11.         int compteur = 0;
  12.        
  13.         System.out.println("SERVEUR CREE, MAINTENANT JATTENDS UNE CONNEXION");
  14.         Socket clientFJ1 = serveurFJ1.accept(); // Attente d'une connection avec la socket
  15.         System.out.println("JAI TROUVER UN CLIENT");
  16.         OutputStream socketOut = clientFJ1.getOutputStream(); // Ouverture d'un flux de sortie
  17.         identiteJoueur1 = new ObjectOutputStream(socketOut); //Le flux de sortie est maintenant déterminé pour les Object
  18.        
  19.         identiteJoueur1.writeObject(identiteJ1); // Sérialisation de(s) object reçu
  20.         identiteJoueur1.flush(); // Vidage mémoire tampon de l'object
  21.    
  22.         System.out.println("Jai flush");
  23.  
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement