| /*** |
| * $RCSfile: weatherTelnet.java,v $ $Revision: 1.1 $ $Date: 2002/04/03 01:04:25 $ |
| * |
| * NetComponents Internet Protocol Library |
| * Copyright (C) 1997-2002 Daniel F. Savarese |
| * |
| * This library is free software; you can redistribute it and/or |
| * modify it under the terms of the GNU Lesser General Public |
| * License as published by the Free Software Foundation; either |
| * version 2.1 of the License, or (at your option) any later version. |
| * |
| * This library 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 |
| * Lesser General Public License for more details. |
| * |
| * You should have received a copy of the GNU Lesser General Public |
| * License along with this library in the LICENSE file; if not, write |
| * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
| * Boston, MA 02111-1307 USA |
| ***/ |
| |
| import java.io.*; |
| |
| import com.oroinc.net.telnet.*; |
| import com.oroinc.io.*; |
| |
| /*** |
| * This is an example of a trivial use of the TelnetClient class. |
| * It connects to the weather server at the University of Michigan, |
| * um-weather.sprl.umich.edu port 3000, and allows the user to interact |
| * with the server via standard input. You could use this example to |
| * connect to any telnet server, but it is obviously not general purpose |
| * because it reads from standard input a line at a time, making it |
| * inconvenient for use with a remote interactive shell (you would use the |
| * terminal emulator in NetComponents Pro for that). The TelnetClient |
| * class used by itself is mostly intended for automating access to telnet |
| * resources rather than interactive use. |
| * <p> |
| ***/ |
| |
| // This class requires the IOUtil support class! |
| public final class weatherTelnet { |
| |
| public final static void main(String[] args) { |
| TelnetClient telnet; |
| |
| telnet = new TelnetClient(); |
| |
| try { |
| telnet.connect("rainmaker.wunderground.com", 3000); |
| } catch(IOException e) { |
| e.printStackTrace(); |
| System.exit(1); |
| } |
| |
| IOUtil.readWrite(telnet.getInputStream(), telnet.getOutputStream(), |
| System.in, System.out); |
| |
| try { |
| telnet.disconnect(); |
| } catch(IOException e) { |
| e.printStackTrace(); |
| System.exit(1); |
| } |
| |
| System.exit(0); |
| } |
| |
| } |
| |
| |