hio.core.wms.wmsing

hio.core.wms.wmsing Module

WinMailSlots as datagram transport

Module Contents

class hio.core.wms.wmsing.Peer(*, umask=None, bc=None, bs=None, wl=None, reopen=False, clear=True, filed=False, extensioned=True, **kwa)

Bases: hio.base.filing.Filer

Class to manage reliable datagram transport on Windows using Mailslots instead of unix domain sockets. WinMailSlot (wms)

Because win-mail-slots (wms) are reliable no need for retry timer. Because win-mail-slots do not attach the source address we have to embed the source address in the memogram header. So we need a new memogram header code for wms as reliable transport replacement for uxd on Windows.

Inherited Class Attributes:

HeadDirPath (str): default abs dir path head such as “/usr/local/var” TailDirPath (str): default rel dir path tail when using head CleanTailDirPath (str): default rel dir path tail when creating clean AltHeadDirPath (str): default alt dir path head such as “~” as fallback when desired head not permitted. AltTailDirPath (str): default alt rel dir path tail as fallback when using alt head. AltCleanTailDirPath (str): default alt rel path tail when creating clean TempHeadDir (str): default temp abs dir path head such as “/tmp” TempPrefix (str): default rel dir path prefix when using temp head TempSuffix (str): default rel dir path suffix when using temp head and tail Perm (int): explicit default octal perms such as 0o1700 Mode (str): open mode such as “r+” Fext (str): default file extension such as “text” for “fname.text”

Inherited Attributes:

name (str): unique path component used in directory or file path name base (str): another unique path component inserted before name temp (bool): True means use TempHeadDir in /tmp directory headDirPath (str): head directory path path (str or None): full directory or file path once created else None perm (int): numeric os permissions for directory and/or file(s) filed (bool): True means .path ends in file; False means .path ends in directory. mode (str): file open mode if filed fext (str): file extension if filed file (File or None): File instance when filed and created. opened (bool): True means directory path, uxd file, and socket are created and opened; False otherwise.

Class Attributes:

Umask (int): octal default umask permissions such as 0o022 MaxGramSize (int): max bytes in in datagram for this transport BufSize (int): used to set buffer size for transport datagram buffers

umask

permission mask for uxd file, usually octal 0o022; .umask is applied after .perm is set if any.

Type:

int

bc

count of transport buffers of MaxGramSize

Type:

int or None

bs

buffer size of transport buffers. When .bc then .bs is calculated by multiplying (.bs = .bc * .MaxGramSize). When .bc is None then .bs is provided value or default .BufSize.

Type:

int

wl

instance ref for debug logging of over the wire tx and rx

Type:

WireLog

ls

local slot of this Peer

Type:

socket.socket

open()

Opens mailslot in nonblocking mode

reopen()

Clear the ms and reopen

close()

Close the mailslot

receive()

Perform a non-blocking read on the mailslot

Returns:

(data, sa). If no data, returns (b’’, None), but always returns a tuple with 2 elements.

Return type:

tuple

Notes

win32file.ReadFile returns a tuple: (errcode, data).

send(data, dest)

Perform a non-blocking write on the mailslot data is string in python2 and bytes in python3 dest is destination mailslot path

Parameters:
  • data (bytes) – to send

  • dest (Mailslot) – destination mailslot