//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void initstr(String hostName, byte addr[] , String ifname) throws UnknownHostException private void Initstr(String hostName, sbyte[] addr, String ifname) { try { NetworkInterface nif = NetworkInterface.GetByName(ifname); if (nif == null) { throw new UnknownHostException("no such interface " + ifname); } Initif(hostName, addr, nif); } catch (SocketException) { throw new UnknownHostException("SocketException thrown" + ifname); } }
/// <summary> /// restore the state of this object from stream /// including the scope information, only if the /// scoped interface name is valid on this system /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException private void ReadObject(ObjectInputStream s) { NetworkInterface scope_ifname = null; if (this.GetType().ClassLoader != null) { throw new SecurityException("invalid address type"); } ObjectInputStream.GetField gf = s.ReadFields(); sbyte[] ipaddress = (sbyte[])gf.Get("ipaddress", null); int scope_id = (int)gf.Get("scope_id", -1); bool scope_id_set = (bool)gf.Get("scope_id_set", false); bool scope_ifname_set = (bool)gf.Get("scope_ifname_set", false); String ifname = (String)gf.Get("ifname", null); if (ifname != null && !"".Equals(ifname)) { try { scope_ifname = NetworkInterface.GetByName(ifname); if (scope_ifname == null) { /* the interface does not exist on this system, so we clear * the scope information completely */ scope_id_set = false; scope_ifname_set = false; scope_id = 0; } else { scope_ifname_set = true; try { scope_id = DeriveNumericScope(ipaddress, scope_ifname); } catch (UnknownHostException) { // typically should not happen, but it may be that // the machine being used for deserialization has // the same interface name but without IPv6 configured. } } } catch (SocketException) { } } /* if ifname was not supplied, then the numeric info is used */ ipaddress = ipaddress.clone(); // Check that our invariants are satisfied if (ipaddress.Length != INADDRSZ) { throw new InvalidObjectException("invalid address length: " + ipaddress.Length); } if (Holder_Renamed.Family != IPv6) { throw new InvalidObjectException("invalid address family type"); } Inet6AddressHolder h = new Inet6AddressHolder(this, ipaddress, scope_id, scope_id_set, scope_ifname, scope_ifname_set); UNSAFE.putObject(this, FIELDS_OFFSET, h); }