home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / sun / net / NetworkClient.class (.txt) next >
Encoding:
Java Class File  |  1998-04-23  |  1.4 KB  |  50 lines

  1. package sun.net;
  2.  
  3. import java.io.BufferedInputStream;
  4. import java.io.BufferedOutputStream;
  5. import java.io.IOException;
  6. import java.io.InputStream;
  7. import java.io.PrintStream;
  8. import java.net.Socket;
  9. import java.net.UnknownHostException;
  10.  
  11. public class NetworkClient {
  12.    protected Socket serverSocket;
  13.    public PrintStream serverOutput;
  14.    public InputStream serverInput;
  15.  
  16.    public void openServer(String var1, int var2) throws IOException, UnknownHostException {
  17.       if (this.serverSocket != null) {
  18.          this.closeServer();
  19.       }
  20.  
  21.       this.serverSocket = this.doConnect(var1, var2);
  22.       this.serverOutput = new PrintStream(new BufferedOutputStream(this.serverSocket.getOutputStream()), true);
  23.       this.serverInput = new BufferedInputStream(this.serverSocket.getInputStream());
  24.    }
  25.  
  26.    protected Socket doConnect(String var1, int var2) throws IOException, UnknownHostException {
  27.       return new Socket(var1, var2);
  28.    }
  29.  
  30.    public void closeServer() throws IOException {
  31.       if (this.serverIsOpen()) {
  32.          this.serverSocket.close();
  33.          this.serverSocket = null;
  34.          this.serverInput = null;
  35.          this.serverOutput = null;
  36.       }
  37.    }
  38.  
  39.    public boolean serverIsOpen() {
  40.       return this.serverSocket != null;
  41.    }
  42.  
  43.    public NetworkClient(String var1, int var2) throws IOException {
  44.       this.openServer(var1, var2);
  45.    }
  46.  
  47.    public NetworkClient() {
  48.    }
  49. }
  50.