Example #1
0
    def __init__(self, address, port):

        if address is not None and len(address) > 0:
            try:
                socket.inet_aton(address)
            except socket.error:
                try:
                    ifconfig = network.ifconfig()
                except network.IfConfigNotSupported:
                    raise InterfaceNotFound(address)

                if address in ifconfig:
                    iff = ifconfig[address]
                else:
                    raise InterfaceNotFound(address)
                self.local_address = iff.ip
            else:
                self.local_address = address
        else:
            self.local_address = None

        if self.local_address is None: self.local_address = ''

        self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        self.address = address
        self.port = port
        self.multicast = False

        self.bind()
Example #2
0
    def __init__(self, address, port):
        
        if address is not None and len(address) > 0:
            try:
                socket.inet_aton ( address )
            except socket.error:           
                try: 
                    ifconfig = network.ifconfig()
                except network.IfConfigNotSupported:
                    raise InterfaceNotFound(address)
                
                if address in ifconfig:
                    iff = ifconfig[address]
                else:
                    raise InterfaceNotFound (address)
                self.local_address = iff.ip
            else:
                self.local_address = address
        else:
            self.local_address = None

        if self.local_address is None: self.local_address = ''

        self._socket = socket.socket (socket.AF_INET, socket.SOCK_DGRAM)
        self._socket.setsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        
        self.address = address
        self.port = port
        self.multicast = False

        self.bind()
Example #3
0
def show_ip():
    r = ifconfig()
    if r:
        colorinfo.show_info(r)
def get_ip():
    if network.WLAN().isconnected():
        return network.ifconfig()[0]
    else:
        return "0.0.0.0"
Example #5
0
def show_ip():
    r = ifconfig()
    if r:
        colorinfo.show_info(r)