public void run() { CConn cc = null; Socket sock = null; if (listenMode.getValue()) { int port = 5500; ServerSocket listener = null; if (vncServerName.getValue() != null && Character.isDigit(vncServerName.getValue().charAt(0))) port = Integer.parseInt(vncServerName.getValue()); try { listener = new ServerSocket(port); } catch (IOException e) { System.out.println("Could not listen on port: " + port); System.exit(-1); } vlog.info("Listening on port " + port); try { sock = listener.accept(); listener.close(); } catch (IOException e) { System.out.println("Accept failed: " + port); System.exit(-1); } } try { cc = new CConn(this, sock, vncServerName.getValue(), false); while (true) cc.processMsg(); } catch (EndOfStream e) { vlog.info(e.toString()); } catch (java.lang.Exception e) { if (cc != null) cc.deleteWindow(); if (cc == null || !cc.shuttingDown) { e.printStackTrace(); JOptionPane.showMessageDialog( null, e.toString(), "VNC Viewer : Error", JOptionPane.ERROR_MESSAGE); } } if (cc != null) cc.deleteWindow(); nViewers--; if (!applet && nViewers == 0) { System.exit(0); } }
public static void usage() { String usage = ("\nusage: vncviewer [options/parameters] " + "[host:displayNum] [options/parameters]\n" + " vncviewer [options/parameters] -listen [port] " + "[options/parameters]\n" + "\n" + "Options:\n" + " -log <level> configure logging level\n" + "\n" + "Parameters can be turned on with -<param> or off with " + "-<param>=0\n" + "Parameters which take a value can be specified as " + "-<param> <value>\n" + "Other valid forms are <param>=<value> -<param>=<value> " + "--<param>=<value>\n" + "Parameter names are case-insensitive. The parameters " + "are:\n\n" + Configuration.listParams()); System.err.print(usage); System.exit(1); }
public static void main(String[] argv) { try { String os = System.getProperty("os.name"); if (os.startsWith("Windows")) { String laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; UIManager.setLookAndFeel(laf); } else { UIManager.put("swing.boldMetal", Boolean.FALSE); javax.swing.plaf.FontUIResource f = new javax.swing.plaf.FontUIResource("SansSerif", Font.PLAIN, 11); java.util.Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof javax.swing.plaf.FontUIResource) UIManager.put(key, f); } } UIManager.put("TitledBorder.titleColor", Color.blue); } catch (java.lang.Exception exc) { } VncViewer viewer = new VncViewer(argv); viewer.start(); }