multicast.skt
Socket utility functions for multicast communication.
Provides helper functions for creating and managing multicast sockets.
NOT intended for DIRECT use!
Caution: See details regarding dynamic imports documented in this module.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
Testcase 0: Multicast should be importable.
>>> import multicast
>>> multicast.skt is not None
True
>>> multicast.skt.__doc__ is not None
True
>>>
Testcase 1: SKT utils should be automatically imported. A: Test that the multicast.skt component is initialized. B: Test that the skt component is initialized. C: Test that the skt component has doc
>>> multicast is not None
True
>>> multicast.skt is not None
True
>>> multicast.skt.__doc__ is not None
True
>>> type(multicast.skt.__doc__) == type(str(''''''))
True
>>>
Testcase 2: SKT utils should be detailed with some metadata. A: Test that the MAGIC variables are initialized. B: Test that the MAGIC variables are strings.
>>> multicast.skt is not None
True
>>> multicast.skt.__module__ is not None
True
>>> multicast.skt.__package__ is not None
True
>>> type(multicast.skt.__doc__) == type(multicast.skt.__module__)
True
>>>
Module Contents
Functions
Create and configure a multicast socket. |
|
Close a multicast socket and release resources. |
Data
The package of this program. |
|
The module of this program. |
|
The file of this component. |
|
The name of this component. |
API
- multicast.skt.__package__[source]
‘multicast’
The package of this program.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
Testcase 0: Multicast should be importable.
>>> import multicast >>>Testcase 1: SKT utils should be automatically imported.
>>> multicast.skt.__package__ is not None True >>> >>> multicast.skt.__package__ == multicast.__package__ True >>>
- multicast.skt.__module__[source]
‘multicast.skt’
The module of this program.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
Testcase 0: Multicast should be importable.
>>> import multicast >>>Testcase 1: SKT utils should be automatically imported.
>>> multicast.skt.__module__ is not None True >>>
- multicast.skt.__file__[source]
‘multicast/skt.py’
The file of this component.
- multicast.skt.__name__[source]
‘multicast.skt’
The name of this component.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
Testcase 0: Multicast should be importable.
>>> import multicast >>>Testcase 1: SKT utils should be automatically imported.
>>> multicast.skt.__name__ is not None True >>>
- multicast.skt.genSocket()[source][source]
Create and configure a multicast socket.
Generates an unbound socket.socket object ready to receive network traffic. Implementation allows reuse of socket (to allow another instance of python running this script binding to the same ip/port).
Returns: socket.socket: A configured multicast socket ready for communication.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
>>> import multicast >>> multicast.__doc__ is not None True >>>Testcase 0: skt should be automatically imported. A: Test that the multicast component is initialized. B: Test that the skt component is initialized.
>>> multicast is not None True >>> multicast.skt is not None True >>>Testcase 1: skt should have genSocket() function that returns a socket.socket object. A: Test that the skt component has the function ‘genSocket’ B: Test that the ‘genSocket’ function returns a socket
>>> multicast.skt.genSocket is not None True >>> multicast.skt.genSocket #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS <function genSocket at ...> >>> type(multicast.skt.genSocket) <class 'function'> >>> test_sock = multicast.skt.genSocket() >>> type(test_sock) <class 'socket.socket'> >>> multicast.endSocket(test_sock)
- multicast.skt.endSocket(sock=None)[source][source]
Close a multicast socket and release resources.
Args: sock (socket.socket, optional): The socket to close. Defaults to None.
Returns: None
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
>>> import multicast >>> multicast.__doc__ is not None True >>>Testcase 0: skt should be automatically imported. A: Test that the multicast component is initialized. B: Test that the skt component is initialized.
>>> multicast is not None True >>> multicast.skt is not None True >>>Testcase 1: skt should have endSocket() function that takes a socket.socket and closes it. A: Test that the skt component has the function ‘genSocket’ B: Test that the skt component has the function ‘endSocket’ C: Test that the ‘endSocket’ function returns None when given the genSocket
>>> multicast.skt.genSocket is not None True >>> multicast.skt.endSocket is not None True >>> multicast.skt.endSocket #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS <function endSocket at ...> >>> type(multicast.skt.endSocket) <class 'function'> >>> temp_fxtr = multicast.skt.endSocket(multicast.skt.genSocket()) >>> temp_fxtr is None True >>>Testcase 2: skt should have endSocket() function that takes a socket.socket object, otherwise does nothing. A: Test that the skt component has the function ‘endSocket’ (see testcase 1) B: Test that the ‘endSocket’ function returns nothing
>>> multicast.skt.endSocket is not None True >>> multicast.skt.endSocket #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS <function endSocket at ...> >>> type(multicast.skt.endSocket) <class 'function'> >>> multicast.skt.endSocket(None) is None True >>>