Did I find the right examples for you? yes no

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Test if a given port number is free for use.

test_port:
    This is the UDP port to test.

returned:
    True: 
        Port is available for use.
    False
        Port not available.(more...)

        def is_free(test_port):
    """Test if a given port number is free for use.
    
    test_port:
        This is the UDP port to test.
    
    returned:
        True: 
            Port is available for use.
        False
            Port not available.
                
    """
    returned = True
    
    client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        client_socket.bind(('', test_port))
        client_socket.close()
        
    except socket.error, e:
        returned = False
    
    return returned
        


src/a/u/autoconnect-0.9.3/lib/autoconnect/receiver.py   autoconnect(Download)
    while True:
        port = random.choice(port_range)
        if util.is_free(port):
            break
        else:

src/a/u/autoconnect-0.9.3/lib/autoconnect/__init__.py   autoconnect(Download)
from broadcaster import beacon
from broadcaster import UdpBroadcaster
from util import is_free
from util import random_ports
from util import FreePortError