Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package compito;
- import java.util.*;
- import java.io.*;
- import java.net.*;
- //@author Jordi Cabrera
- public class MyClient {
- public static void main(String[] args) {
- try{
- Socket s=new Socket("localhost",6969); //inizializza la connessione con la porta 6969 su localhost
- Scanner input = new Scanner(System.in);
- Scanner in = new Scanner(s.getInputStream()); //Oggetto per prendere i messaggi in arrivo dal server
- PrintWriter out = new PrintWriter(s.getOutputStream(), true); //Oggetto per mandare un messaggio al server
- int logged=0;
- while(logged==0){
- out.println(input.nextLine()); //messaggio da mandare al server
- /* while(in.nextLine().equals("false"))*/ System.out.println("Username '"+in.nextLine()+"' accettato");
- out.println(input.nextLine()); //messaggio da mandare al server
- System.out.println("Password '"+in.nextLine()+"' accettato");
- logged=1;
- }
- s.close(); //chiude la connessione
- }catch(Exception e){System.out.println(e);}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement