home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-08-19 | 868 b | 36 lines |
- import netscape.server.applet.*;
-
- import java.io.PrintStream;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.io.DataInputStream;
- import java.net.Socket;
-
- class Connect extends HttpApplet {
-
- public void run() throws Exception {
-
- String host = "www.meer.net";
- int port = 80;
- String request = "GET /barn/index.html HTTP/1.0\n";
-
- Socket s = new Socket(host, port);
- OutputStream os = s.getOutputStream();
- PrintStream op = new PrintStream(os);
-
- op.println(request);
-
- InputStream is = s.getInputStream();
- DataInputStream di = new DataInputStream(is);
- String line;
-
- if (returnNormalResponse("text/html")) {
- PrintStream out = getOutputStream();
- out.println("<h1>Data on "+host+" port "+port+"</h1>");
- out.println("<b>request: "+request+"</b><hr>");
- while ((line = di.readLine()) != null)
- out.println(line);
- }
- }
- }
-