예제 #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()
예제 #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()
예제 #3
0
파일: main.py 프로젝트: pengxiaojun/ipsan
def show_ip():
    r = ifconfig()
    if r:
        colorinfo.show_info(r)
예제 #4
0
def get_ip():
    if network.WLAN().isconnected():
        return network.ifconfig()[0]
    else:
        return "0.0.0.0"
예제 #5
0
파일: main.py 프로젝트: BillTheBest/ipsan
def show_ip():
    r = ifconfig()
    if r:
        colorinfo.show_info(r)