4 import java.net.InetAddress;
9 private static LocalHost Instance ;
10 private static String name ;
13 private int socketPort = 1097 ;
14 private static ServicesClient ref = null ;
15 private static ServicesServer refServer = null ;
16 private boolean startedThreads = false ;
20 if ( System.getSecurityManager() == null )
22 System.setSecurityManager( new SecurityManager() ) ;
25 InetAddress ia = InetAddress.getLocalHost() ;
26 name = ia.getCanonicalHostName() ;
27 IP = ia.getHostAddress() ;
28 } catch( Exception e ) {
29 System.err.println( "Error: Unknown Host: " + e ) ;
33 public int getSocketPort() {
37 public synchronized static LocalHost Instance() {
38 if (Instance == null) {
39 Instance = new LocalHost() ;
48 public String resolve( String name ) {
51 ip = InetAddress.getByName(name).getHostAddress() ;
52 } catch (java.net.UnknownHostException e) {
53 System.err.println( "Cannot find IP address of " + name + ":" + e ) ;
58 public synchronized void setPort( int portOfComm ) {
62 public int getPort() {
66 public synchronized String getName() {
70 public synchronized String getIP() {
74 public synchronized void setStub(ServicesClient stub) {
79 public synchronized void setServerStub(ServicesServer stub) {
84 public ServicesServer getServerStub() {
88 public synchronized ServicesClient getStub() {
92 public synchronized void setStartedThreads( boolean b ) {
96 public synchronized boolean getStartedThreads() {
97 return startedThreads ;
102 /** La programmation est un art, respectons ceux qui la pratiquent !! **/