Package master_discovery_fkie :: Module udp :: Class McastSocket
[frames] | no frames]

Class McastSocket

source code

          object --+    
                   |    
socket._socketobject --+
                       |
                      McastSocket

The McastSocket class enables the send and receive UDP messages to a multicast group.

Instance Methods
socket object

__init__(self, port, mgroup, reuse=True, ttl=20)
Creates a socket, bind it to a given port and join to a given multicast group.
source code
 
close(self)
Unregister from the multicast group and close the socket.
source code
 
send2group(self, msg)
Sends the given message to the joined multicast group.
source code
 
send2addr(self, msg, addr)
Sends the given message to the joined multicast group.
source code
boolean
hasEnabledMulticastIface(self)
Test all enabled interfaces for a MULTICAST flag.
source code

Inherited from socket._socketobject: accept, bind, connect, connect_ex, dup, fileno, getpeername, getsockname, getsockopt, gettimeout, listen, makefile, sendall, setblocking, setsockopt, settimeout, shutdown

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods
[(str, str)]
localifs()
Used to get a list of the up interfaces and associated IP addresses on this machine (linux only).
source code
Class Variables

Inherited from socket._socketobject: __doc__

Properties

Inherited from socket._socketobject: family, proto, recv, recv_into, recvfrom, recvfrom_into, send, sendto, type

Inherited from object: __class__

Method Details

__init__(self, port, mgroup, reuse=True, ttl=20)
(Constructor)

source code 

Creates a socket, bind it to a given port and join to a given multicast group. IPv4 and IPv6 are supported.

Parameters:
  • port (int) - the port to bind the socket
  • mgroup (str) - the multicast group to join
  • reuse (boolean (Default: True)) - allows the reusing of the port
  • ttl (int (Default: 20)) - time to leave
Returns:
socket object

Overrides: object.__init__

close(self)

source code 

Unregister from the multicast group and close the socket.

Overrides: socket._socketobject.close

send2group(self, msg)

source code 

Sends the given message to the joined multicast group. Some errors on send will be ignored (ENETRESET, ENETDOWN, ENETUNREACH)

Parameters:
  • msg (str) - message to send

send2addr(self, msg, addr)

source code 

Sends the given message to the joined multicast group. Some errors on send will be ignored (ENETRESET, ENETDOWN, ENETUNREACH)

Parameters:
  • msg (str) - message to send
  • addr (str) - IPv4 or IPv6 address

hasEnabledMulticastIface(self)

source code 

Test all enabled interfaces for a MULTICAST flag. If no enabled interfaces has a multicast support, False will be returned.

Returns: boolean
True, if any interfaces with multicast support are enabled.

localifs()
Static Method

source code 

Used to get a list of the up interfaces and associated IP addresses on this machine (linux only).

Returns: [(str, str)]
List of interface tuples. Each tuple consists of (interface name, interface IP)