Package org.gnome.gio
Class InetAddress
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.gobject.TypeInstance
org.gnome.gobject.GObject
org.gnome.gio.InetAddress
- All Implemented Interfaces:
Proxy
GInetAddress
represents an IPv4 or IPv6 internet address. Use
Resolver.lookupByName(java.lang.String, org.gnome.gio.Cancellable)
or
Resolver.lookupByNameAsync(java.lang.String, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
to look up the GInetAddress
for
a hostname. Use Resolver.lookupByAddress(org.gnome.gio.InetAddress, org.gnome.gio.Cancellable)
or
Resolver.lookupByAddressAsync(org.gnome.gio.InetAddress, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
to look up the hostname for a
GInetAddress
.
To actually connect to a remote host, you will need a
InetSocketAddress
(which includes a GInetAddress
as well as a
port number).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
InetAddress.Builder<B extends InetAddress.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionInetAddress
(MemorySegment address) Create a InetAddress proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionstatic InetAddress
any
(SocketFamily family) Creates aGInetAddress
for the "any" address (unassigned/"don't care") forfamily
.protected InetAddress
asParent()
Returns this instance as if it were its parent type.static InetAddress.Builder
<? extends InetAddress.Builder> builder()
AInetAddress.Builder
object constructs aInetAddress
with the specified properties.boolean
equal
(InetAddress otherAddress) Checks if twoGInetAddress
instances are equal, e.g.static InetAddress
fromBytes
(byte[] bytes, SocketFamily family) Creates a newGInetAddress
from the givenfamily
andbytes
.static InetAddress
fromString
(String string) Parsesstring
as an IP address and creates a newGInetAddress
.Gets this InetAddress's familyboolean
getIsAny()
Tests whether this InetAddress is the "any" address for its family.boolean
Tests whether this InetAddress is a link-local address (that is, if it identifies a host on a local network that is not connected to the Internet).boolean
Tests whether this InetAddress is the loopback address for its family.boolean
Tests whether this InetAddress is a global multicast address.boolean
Tests whether this InetAddress is a link-local multicast address.boolean
Tests whether this InetAddress is a node-local multicast address.boolean
Tests whether this InetAddress is an organization-local multicast address.boolean
Tests whether this InetAddress is a site-local multicast address.boolean
Tests whether this InetAddress is a multicast address.boolean
Tests whether this InetAddress is a site-local address such as 10.0.0.1 (that is, the address identifies a host on a local network that can not be reached directly from the Internet, but which may have outgoing Internet connectivity via a NAT or firewall).static MemoryLayout
The memory layout of the native struct.long
Gets the size of the native raw binary address for this InetAddress.static Type
getType()
Get the GType of the InetAddress classstatic InetAddress
loopback
(SocketFamily family) Creates aGInetAddress
for the loopback address forfamily
.toBytes()
Gets the raw binary address data from this InetAddress.toString()
Converts this InetAddress to string form.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
InetAddress
Create a InetAddress proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
any
Creates aGInetAddress
for the "any" address (unassigned/"don't care") forfamily
.- Parameters:
family
- the address family- Returns:
- a new
GInetAddress
corresponding to the "any" address forfamily
. Free the returned object with g_object_unref().
-
fromBytes
Creates a newGInetAddress
from the givenfamily
andbytes
.bytes
should be 4 bytes forSocketFamily.IPV4
and 16 bytes forSocketFamily.IPV6
.- Parameters:
bytes
- raw address datafamily
- the address family ofbytes
- Returns:
- a new
GInetAddress
corresponding tofamily
andbytes
. Free the returned object with g_object_unref().
-
fromString
Parsesstring
as an IP address and creates a newGInetAddress
.- Parameters:
string
- a string representation of an IP address- Returns:
- a new
GInetAddress
corresponding tostring
, ornull
ifstring
could not be parsed. Free the returned object with g_object_unref().
-
loopback
Creates aGInetAddress
for the loopback address forfamily
.- Parameters:
family
- the address family- Returns:
- a new
GInetAddress
corresponding to the loopback address forfamily
. Free the returned object with g_object_unref().
-
equal
Checks if twoGInetAddress
instances are equal, e.g. the same address.- Parameters:
otherAddress
- AnotherGInetAddress
.- Returns:
true
if this InetAddress andotherAddress
are equal,false
otherwise.
-
getFamily
-
getIsAny
public boolean getIsAny()Tests whether this InetAddress is the "any" address for its family.- Returns:
true
if this InetAddress is the "any" address for its family.
-
getIsLinkLocal
public boolean getIsLinkLocal()Tests whether this InetAddress is a link-local address (that is, if it identifies a host on a local network that is not connected to the Internet).- Returns:
true
if this InetAddress is a link-local address.
-
getIsLoopback
public boolean getIsLoopback()Tests whether this InetAddress is the loopback address for its family.- Returns:
true
if this InetAddress is the loopback address for its family.
-
getIsMcGlobal
public boolean getIsMcGlobal()Tests whether this InetAddress is a global multicast address.- Returns:
true
if this InetAddress is a global multicast address.
-
getIsMcLinkLocal
public boolean getIsMcLinkLocal()Tests whether this InetAddress is a link-local multicast address.- Returns:
true
if this InetAddress is a link-local multicast address.
-
getIsMcNodeLocal
public boolean getIsMcNodeLocal()Tests whether this InetAddress is a node-local multicast address.- Returns:
true
if this InetAddress is a node-local multicast address.
-
getIsMcOrgLocal
public boolean getIsMcOrgLocal()Tests whether this InetAddress is an organization-local multicast address.- Returns:
true
if this InetAddress is an organization-local multicast address.
-
getIsMcSiteLocal
public boolean getIsMcSiteLocal()Tests whether this InetAddress is a site-local multicast address.- Returns:
true
if this InetAddress is a site-local multicast address.
-
getIsMulticast
public boolean getIsMulticast()Tests whether this InetAddress is a multicast address.- Returns:
true
if this InetAddress is a multicast address.
-
getIsSiteLocal
public boolean getIsSiteLocal()Tests whether this InetAddress is a site-local address such as 10.0.0.1 (that is, the address identifies a host on a local network that can not be reached directly from the Internet, but which may have outgoing Internet connectivity via a NAT or firewall).- Returns:
true
if this InetAddress is a site-local address.
-
getNativeSize
public long getNativeSize()Gets the size of the native raw binary address for this InetAddress. This is the size of the data that you get from g_inet_address_to_bytes().- Returns:
- the number of bytes used for the native version of this InetAddress.
-
toBytes
Gets the raw binary address data from this InetAddress.- Returns:
- a pointer to an internal array of the bytes in this InetAddress, which should not be modified, stored, or freed. The size of this array can be gotten with g_inet_address_get_native_size().
-
toString
-
builder
AInetAddress.Builder
object constructs aInetAddress
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withInetAddress.Builder.build()
.
-