From: Carsten W. <ca...@us...> - 2004-10-17 20:33:27
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4845/src/jake2/qcommon Modified Files: netadr_t.java Log Message: nonblocking network and code cleanup Index: netadr_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/netadr_t.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** netadr_t.java 17 Oct 2004 20:20:09 -0000 1.3 --- netadr_t.java 17 Oct 2004 20:33:18 -0000 1.4 *************** *** 23,26 **** --- 23,28 ---- package jake2.qcommon; + import jake2.Defines; + import java.net.InetAddress; import java.net.UnknownHostException; *************** *** 32,45 **** public int port; ! public byte ip[] = { 0, 0, 0, 0 }; ! ! //public byte ipx[] = new byte[10]; InetAddress ia = null; public InetAddress getInetAddress() throws UnknownHostException { ! if (ia == null) ia = InetAddress.getByAddress(ip); ! return ia; } --- 34,58 ---- public int port; ! public byte ip[]; InetAddress ia = null; + public netadr_t() { + this.type = Defines.NA_LOOPBACK; + this.port = 0; // any + try { + this.ip = InetAddress.getByName("localhost").getAddress(); + } catch (UnknownHostException e) { + } + } + public InetAddress getInetAddress() throws UnknownHostException { ! if (type == Defines.NA_BROADCAST) { ! ia = InetAddress.getByName("255.255.255.255"); ! } else if (type == Defines.NA_LOOPBACK) { ! ia = InetAddress.getByName("localhost"); ! } else if (ia == null) { ia = InetAddress.getByAddress(ip); ! } return ia; } |