py2neo.wiring – Low-level network operations

Low-level module for network communication.

This module provides a convenience socket wrapper class (Wire) as well as classes for modelling IP addresses, based on tuples.

class py2neo.wiring.Address[source]

Address of a machine on a network.

family = None

Address family (AF_INET or AF_INET6)

exception py2neo.wiring.BrokenWireError(*args, **kwargs)[source]

Raised when a connection is broken by the network or remote peer.

class py2neo.wiring.IPv4Address[source]

Address subclass, specifically for IPv4 addresses.

class py2neo.wiring.IPv6Address[source]

Address subclass, specifically for IPv6 addresses.

class py2neo.wiring.Wire(s, on_broken=None)[source]

Buffered socket wrapper for reading and writing bytes.

broken

Flag indicating whether this connection has been closed remotely.

close()[source]

Close the connection.

closed

Flag indicating whether this connection has been closed locally.

local_address

The local Address to which this connection is bound.

classmethod open(address, timeout=None, keep_alive=False, on_broken=None)[source]

Open a connection to a given network Address.

Parameters:
  • address
  • timeout
  • keep_alive
  • on_broken – callback for when the wire is broken after a successful connection has first been established (this does not trigger if the connection never opens successfully)
Returns:

Wire object

Raises:

WireError – if connection fails to open

peek()[source]

Return any buffered unread data.

read(n)[source]

Read bytes from the network.

remote_address

The remote Address to which this connection is bound.

secure(verify=True, hostname=None)[source]

Apply a layer of security onto this connection.

send()[source]

Send the contents of the output buffer to the network.

write(b)[source]

Write bytes to the output buffer.

exception py2neo.wiring.WireError(*args, **kwargs)[source]

Raised when a connection error occurs.

Parameters:
  • idle_time
  • bytes_sent
  • bytes_received
class py2neo.wiring.WireRequestHandler(request, client_address, server)[source]

Base handler for use with the socketserver module that wraps the request attribute as a Wire object.