Module inovopy.socket

Socket Module

This module provide api for handle generic socket communication for communicating with robot for control.

Class

  • TcpListener : A class for managing listening socket connection
  • TcpStream : A class for managing socket communication to a client
  • SocketExecption : An Excpetion Class for all socket related exception

Example

from inovopy.socket import TcpListener, TcpStream

listener = TcpListener()               # <-- create a new listener
stream: TcpStream = listener.accept()  # <-- accept a new connection
del(listener)                          # <-- delete the listener to stop listening

stream.write("Send this message")      # <-- send a str message
read_message : str = stream.read()     # <-- read a messagea as str

Sub-modules

inovopy.socket.tcp_listener

TCP Listener Module This module provide an api class for listening tcp connection …

inovopy.socket.tcp_stream

TCP Stream Module This module provide an api class for managing tcp connection …

Functions

def detect_interfaces() ‑> list[str]
Expand source code
def detect_interfaces() -> list[str]:
    """
    try to automatically detect local ip of this machine
    in all local networks

    ## Return:
    `list[str]` a list of ip
    """
    hostname = socket.gethostname()
    if platform.system() == "Linux":
        hostname += ".local"
    return socket.gethostbyname_ex(hostname)[2]

try to automatically detect local ip of this machine in all local networks

Return:

list[str] a list of ip

Classes

class EndOfCommunication (*args, **kwargs)
Expand source code
class EndOfCommunication(Exception):
    """end of communication exception"""

end of communication exception

Ancestors

  • builtins.Exception
  • builtins.BaseException
class SocketException (*args, **kwargs)
Expand source code
class SocketException(Exception):
    """socket commuication exception"""

socket commuication exception

Ancestors

  • builtins.Exception
  • builtins.BaseException