/* * * On Netscape Navigator 2.0, an applet can only make a connection * to the computer that it came from. This is either the http * server named in the applet's URL, or the server named in the URL * given in the applet's CODEBASE parameter. * * Attempting to connect to any other host on the internet should * raise a security exception. * * By default, the same holds for appletviewer. If you place * appletviewer in "unrestricted" browse mode, then applets can * make arbitrary connections. For this reason, it is strongly * suggested that you do not use appletviewer in "unrestricted" * mode if you use it to load foreign applets. * * @version JDK 1.0 beta * @author Marianne Mueller */ /* These ports can often be connected to * on the originating host if it is running Solaris: * 7 9 13 19 21 23 25 37 79 80 111 512 513 514 540 872 */ import java.awt.*; import java.net.*; import java.io.*; import java.lang.*; import java.applet.*; public class port25 extends Applet { final String host = "www.netscape.com"; int port = 25; public void paint(Graphics g) { try { Socket s = new Socket(host, port, true); g.drawString("Success connecting to port " + port + " on host " + host, 10, 10); } catch (SecurityException e) { g.drawString("Caught security exception trying to connect to port " + port + " on " + host , 10, 10); } catch (IOException ioe) { g.drawString("paint: caught i/o exception", 10, 10); } } }