⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conexion.java

📁 multiplataform real time Linux monitor
💻 JAVA
字号:
/** LiMon-JClient *  Copyright (C) 2006 Marcelo Busico * *  Author:  Marcelo Busico    marcelobusico@gmail.com * *  This program is free software which I release under the GNU General Public *  License. You may redistribute and/or modify this program under the terms *  of that license as published by the Free Software Foundation; either *  version 2 of the License, or (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details.  Version 2 is in the *  LICENSE.txt file in the top level directory of this distribution. *  *  To get a copy of the GNU General Puplic License, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package limonclient;import java.io.*;import java.net.*;import java.lang.*;public class Conexion {    private String direccion;    private int puerto;    private String password;    private Socket servidor;    private DataInputStream entrada;    private DataOutputStream salida;        /** Crea una nueva instancia de Conexion */    public Conexion(String dir, int pu, String pass) throws IOException {        direccion=dir;        puerto=pu;        password=pass;        //Lo siguiente puede lanzar una IOException        servidor=new Socket(direccion,puerto);        entrada = new DataInputStream(servidor.getInputStream());        salida = new DataOutputStream(servidor.getOutputStream());    }        //Devuelve la direccion del servidor    public String getDireccion()    {        return direccion;    }    //Devuelve el puerto del servidor    public int getPuerto()    {        return puerto;    }    //Devuelve la password usada en la conexion    public String getPassword()    {        return password;    }        //Cierra la conexion con el servidor    public void cerrarConexion() throws IOException    {        //Envia peticion de desconexion        Cabecera envCab=new Cabecera(Cabecera.IdDesconexion,password);        //Lo siguiente puede lanzar una IOException        envCab.enviarCabecera(salida);        entrada.close();        salida.close();        servidor.close();    }        //Devuelve verdadero si la conexion con el servidor esta establecida    public boolean isConnected()    {        if(salida!=null)            return true;        else            return false;    }        //Devuelve el Stream de Salida con el servidor    public DataOutputStream getSalida()    {        return salida;    }        //Devuelve el Stream de Entrada con el servidor    public DataInputStream getEntrada()    {        return entrada;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -