Package org.gnome.gio
Class InetAddress
java.lang.Object
org.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
Nested ClassesModifier and TypeClassDescriptionstatic classInetAddress.Builder<B extends InetAddress.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new InetAddress.InetAddress(MemorySegment address) Create a InetAddress proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionstatic InetAddressany(SocketFamily family) Creates aGInetAddressfor the "any" address (unassigned/"don't care") forfamily.protected InetAddressasParent()Returns this instance as if it were its parent type.static InetAddress.Builder<? extends InetAddress.Builder> builder()AInetAddress.Builderobject constructs aInetAddresswith the specified properties.booleanequal(InetAddress otherAddress) Checks if twoGInetAddressinstances are equal, e.g.static InetAddressfromBytes(@org.jspecify.annotations.Nullable byte @Nullable [] bytes, SocketFamily family) Creates a newGInetAddressfrom the givenfamilyandbytes.bytesshould be 4 bytes forSocketFamily.IPV4and 16 bytes forSocketFamily.IPV6.static InetAddressfromBytesWithIpv6Info(@org.jspecify.annotations.Nullable byte @Nullable [] bytes, SocketFamily family, int flowinfo, int scopeId) static InetAddressfromString(String string) Parsesstringas an IP address and creates a newGInetAddress.Getsaddress'sfamilyintGets the value ofGio.InetAddress:flowinfo.booleangetIsAny()Tests whether this InetAddress is the "any" address for its family.booleanTests 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).booleanTests whether this InetAddress is the loopback address for its family.booleanTests whether this InetAddress is a global multicast address.booleanTests whether this InetAddress is a link-local multicast address.booleanTests whether this InetAddress is a node-local multicast address.booleanTests whether this InetAddress is an organization-local multicast address.booleanTests whether this InetAddress is a site-local multicast address.booleanTests whether this InetAddress is a multicast address.booleanTests 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 MemoryLayoutThe memory layout of the native struct.longGets the size of the native raw binary address foraddress.This is the size of the data that you get from g_inet_address_to_bytes().intGets the value ofGio.InetAddress:scope-id.static @Nullable TypegetType()Get the GType of the InetAddress classstatic InetAddressloopback(SocketFamily family) Creates aGInetAddressfor the loopback address forfamily.toBytes()Gets the raw binary address data fromaddress.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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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
-
InetAddress
public InetAddress()Creates a new InetAddress.
-
-
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 Javasuperkeyword, 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 aGInetAddressfor the "any" address (unassigned/"don't care") forfamily.- Parameters:
family- the address family- Returns:
- a new
GInetAddresscorresponding to the "any" address forfamily.Free the returned object with g_object_unref(). - Since:
- 2.22
-
fromBytes
public static InetAddress fromBytes(@org.jspecify.annotations.Nullable byte @Nullable [] bytes, SocketFamily family) Creates a newGInetAddressfrom the givenfamilyandbytes.bytesshould be 4 bytes forSocketFamily.IPV4and 16 bytes forSocketFamily.IPV6.- Parameters:
bytes- raw address datafamily- the address family ofbytes- Returns:
- a new
GInetAddresscorresponding tofamilyandbytes.Free the returned object with g_object_unref(). - Since:
- 2.22
-
fromBytesWithIpv6Info
public static InetAddress fromBytesWithIpv6Info(@org.jspecify.annotations.Nullable byte @Nullable [] bytes, SocketFamily family, int flowinfo, int scopeId) Creates a newInetAddressfrom the givenfamily,bytesandscopeId.bytesmust be 4 bytes forGio.SocketFamily.IPV4and 16 bytes forGio.SocketFamily.IPV6.- Parameters:
bytes- raw address datafamily- the address family ofbytesscopeId- the scope-id of the address- Returns:
- a new internet address corresponding to
family,bytesandscopeId - Since:
- 2.86
-
fromString
Parsesstringas an IP address and creates a newGInetAddress.If
addressis an IPv6 address, it can also contain a scope ID (separated from the address by a%). Note that currently this behavior is platform specific. This may change in a future release.- Parameters:
string- a string representation of an IP address- Returns:
- a new
GInetAddresscorresponding tostring,ornullifstringcould not be parsed. Free the returned object with g_object_unref(). - Since:
- 2.22
-
loopback
Creates aGInetAddressfor the loopback address forfamily.- Parameters:
family- the address family- Returns:
- a new
GInetAddresscorresponding to the loopback address forfamily.Free the returned object with g_object_unref(). - Since:
- 2.22
-
equal
Checks if twoGInetAddressinstances are equal, e.g. the same address.- Parameters:
otherAddress- AnotherGInetAddress.- Returns:
trueif this InetAddress andotherAddressare equal,falseotherwise.- Since:
- 2.30
-
getFamily
-
getFlowinfo
public int getFlowinfo()Gets the value ofGio.InetAddress:flowinfo.- Returns:
- The flowinfo for the address,
0if unset or not IPv6 address. - Since:
- 2.86
-
getIsAny
public boolean getIsAny()Tests whether this InetAddress is the "any" address for its family.- Returns:
trueif this InetAddress is the "any" address for its family.- Since:
- 2.22
-
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:
trueif this InetAddress is a link-local address.- Since:
- 2.22
-
getIsLoopback
public boolean getIsLoopback()Tests whether this InetAddress is the loopback address for its family.- Returns:
trueif this InetAddress is the loopback address for its family.- Since:
- 2.22
-
getIsMcGlobal
public boolean getIsMcGlobal()Tests whether this InetAddress is a global multicast address.- Returns:
trueif this InetAddress is a global multicast address.- Since:
- 2.22
-
getIsMcLinkLocal
public boolean getIsMcLinkLocal()Tests whether this InetAddress is a link-local multicast address.- Returns:
trueif this InetAddress is a link-local multicast address.- Since:
- 2.22
-
getIsMcNodeLocal
public boolean getIsMcNodeLocal()Tests whether this InetAddress is a node-local multicast address.- Returns:
trueif this InetAddress is a node-local multicast address.- Since:
- 2.22
-
getIsMcOrgLocal
public boolean getIsMcOrgLocal()Tests whether this InetAddress is an organization-local multicast address.- Returns:
trueif this InetAddress is an organization-local multicast address.- Since:
- 2.22
-
getIsMcSiteLocal
public boolean getIsMcSiteLocal()Tests whether this InetAddress is a site-local multicast address.- Returns:
trueif this InetAddress is a site-local multicast address.- Since:
- 2.22
-
getIsMulticast
public boolean getIsMulticast()Tests whether this InetAddress is a multicast address.- Returns:
trueif this InetAddress is a multicast address.- Since:
- 2.22
-
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:
trueif this InetAddress is a site-local address.- Since:
- 2.22
-
getNativeSize
public long getNativeSize()Gets the size of the native raw binary address foraddress.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
address. - Since:
- 2.22
-
getScopeId
public int getScopeId()Gets the value ofGio.InetAddress:scope-id.- Returns:
- The scope-id for the address,
0if unset or not IPv6 address. - Since:
- 2.86
-
toBytes
Gets the raw binary address data fromaddress.- Returns:
- a pointer to an internal array of the bytes in
address,which should not be modified, stored, or freed. The size of this array can be gotten with g_inet_address_get_native_size(). - Since:
- 2.22
-
toString
-
builder
AInetAddress.Builderobject constructs aInetAddresswith the specified properties. Use the variousset...()methods to set properties, and finish construction withInetAddress.Builder.build().- Returns:
- the builder object
-