Exemplo n.º 1
0
 public void connect(String user, String pass) {
   if (!connected) {
     try {
       socket = new Socket(domain, 4446);
       out = new PrintWriter(socket.getOutputStream(), true);
       // in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
       in = new ObjectInputStream(socket.getInputStream());
     } catch (java.net.UnknownHostException e) {
       System.err.println("Don't know about host");
       return;
     } catch (IOException e) {
       System.err.println("Couldn't get I/O for the connection to");
       return;
     }
     this.connected = true;
     rec = new Receiver(in);
     rec.start();
   }
 }
Exemplo n.º 2
0
 public void disconnect() {
   int cmdID = commID++;
   this.connected = false;
   try {
     out.println(cmdID + ";logout");
     out.flush();
     in.close();
     out.close();
     socket.close();
   } catch (IOException ex) {
     System.err.println("Server stop failed.");
   }
 }