SocketAddress#

class SocketAddress(**properties: Any)#

Superclasses: Object

Subclasses: InetSocketAddress, NativeSocketAddress, UnixSocketAddress

Implemented Interfaces: SocketConnectable

GSocketAddress is the equivalent of `struct sockaddr <man:sockaddr(3type)>`__ and its subtypes in the BSD sockets API. This is an abstract class; use InetSocketAddress for internet sockets, or UnixSocketAddress for UNIX domain sockets.

Constructors#

class SocketAddress
classmethod new_from_native(native: Any, len: int) SocketAddress#

Creates a SocketAddress subclass corresponding to the native struct sockaddr native.

Added in version 2.22.

Parameters:
  • native – a pointer to a struct sockaddr

  • len – the size of the memory location pointed to by native

Methods#

class SocketAddress
do_get_family(self) SocketFamily#
do_get_native_size(self) int#
do_to_native(self, dest: Any, destlen: int) bool#
Parameters:
  • dest

  • destlen

get_family() SocketFamily#

Gets the socket family type of address.

Added in version 2.22.

get_native_size() int#

Gets the size of address's native struct sockaddr. You can use this to allocate memory to pass to to_native().

Added in version 2.22.

to_native(dest: Any, destlen: int) bool#

Converts a SocketAddress to a native struct sockaddr, which can be passed to low-level functions like connect() or bind().

If not enough space is available, a NO_SPACE error is returned. If the address type is not known on the system then a NOT_SUPPORTED error is returned.

Added in version 2.22.

Parameters:
  • dest – a pointer to a memory location that will contain the native struct sockaddr

  • destlen – the size of dest. Must be at least as large as get_native_size()

Properties#

class SocketAddress
props.family: SocketFamily#

The type of the None singleton.

Added in version 2.22.

Virtual Methods#

class SocketAddress
do_get_family() SocketFamily#

Gets the socket family type of address.

Added in version 2.22.

do_get_native_size() int#

Gets the size of address's native struct sockaddr. You can use this to allocate memory to pass to to_native().

Added in version 2.22.

do_to_native(dest: Any, destlen: int) bool#

Converts a SocketAddress to a native struct sockaddr, which can be passed to low-level functions like connect() or bind().

If not enough space is available, a NO_SPACE error is returned. If the address type is not known on the system then a NOT_SUPPORTED error is returned.

Added in version 2.22.

Parameters:
  • dest – a pointer to a memory location that will contain the native struct sockaddr

  • destlen – the size of dest. Must be at least as large as get_native_size()

Fields#

class SocketAddress
parent_instance#