IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
InetAddressExtensions.cs
Go to the documentation of this file.
1using System.Net;
2
4{
5
10 {
11
12#if !FIRST_PASS
13
19 public static IPAddress ToIPAddress(this java.net.InetAddress self)
20 {
21 if (self == null)
22 return null;
23 else if (self is java.net.Inet6Address ip6)
24 return new IPAddress(self.getAddress(), ip6.getScopeId());
25 else
26 return new IPAddress(self.getAddress());
27 }
28
34 public static java.net.InetAddress ToInetAddress(this IPAddress address)
35 {
36 return address != null ? address.ToInetAddress(address.ToString()) : null;
37 }
38
45 public static java.net.InetAddress ToInetAddress(this IPAddress address, string hostname)
46 {
47 if (address == null)
48 return null;
49 else if (address.IsIPv6LinkLocal || address.IsIPv6SiteLocal)
50 return java.net.Inet6Address.getByAddress(hostname, address.GetAddressBytes(), (int)address.ScopeId);
51 else
52 return java.net.InetAddress.getByAddress(hostname, address.GetAddressBytes());
53 }
54
60 public static java.net.InetAddress ToInetAddress(this IPEndPoint self)
61 {
62 return self != null ? self.Address.ToInetAddress() : null;
63 }
64
65#endif
66
67 }
68
69}
Extension methods for working with Internet Addrsses.
static java.net.InetAddress ToInetAddress(this IPAddress address, string hostname)
Gets a java.net.InetAddress for the given IPAddress.
static IPAddress ToIPAddress(this java.net.InetAddress self)
Gets a IPAddress for the given java.net.InetAddress.
static java.net.InetAddress ToInetAddress(this IPEndPoint self)
Gets a java.net.InetAddress for the given IPEndPoint.
static java.net.InetAddress ToInetAddress(this IPAddress address)
Gets a java.net.InetAddress for the given IPAddress.