Skip to content

Gio.InetSocketAddress

class — extends SocketAddress, SocketConnectable

An IPv4 or IPv6 socket address. That is, the combination of a InetAddress and a port number.

In UNIX terms, GInetSocketAddress corresponds to a struct sockaddr_in or struct sockaddr_in6.

Constructors

new

@classmethod
def new(cls, address: InetAddress, port: int) -> SocketAddress

Creates a new InetSocketAddress for address and port.

Parameters:

new_from_string

@classmethod
def new_from_string(cls, address: str, port: int) -> SocketAddress | None

Creates a new InetSocketAddress for address and port.

If address is 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:

  • address — the string form of an IP address
  • port — a port number

Methods

get_address

def get_address(self) -> InetAddress

Gets address's InetAddress.

get_flowinfo

def get_flowinfo(self) -> int

Gets the sin6_flowinfo field from address, which must be an IPv6 address.

If not overridden this value will be inherited from InetSocketAddress.address.

get_port

def get_port(self) -> int

Gets address's port.

get_scope_id

def get_scope_id(self) -> int

Gets the sin6_scope_id field from address, which must be an IPv6 address.

If not overridden this value will be inherited from InetSocketAddress.address.

Properties

address

address: InetAddress  # read/write

The address.

flowinfo

flowinfo: int  # read/write

The sin6_flowinfo field, for IPv6 addresses.

If unset this property is inherited from InetSocketAddress.address.

port

port: int  # read/write

The port.

scope_id

scope_id: int  # read/write

The sin6_scope_id field, for IPv6 addresses.

If unset this property is inherited from InetSocketAddress.address.