def findFreePort(): """Finds a free server port on this machine and returns it Valid server ports are in the range 18000 upward (the function tries to find the lowest possible port number ATTENTION: this part may introduce race conditions""" return freeServerPort(config().getint("Network","startServerPort"), length=config().getint("Network","nrServerPorts"))
def findFreePort(): """Finds a free server port on this machine and returns it Valid server ports are in the range 18000 upward (the function tries to find the lowest possible port number ATTENTION: this part may introduce race conditions""" return freeServerPort(config().getint("Network", "startServerPort"), length=config().getint("Network", "nrServerPorts"))
def findFreePort(useSSL=None): """Finds a free server port on this machine and returns it Valid server ports are in the range 18000 upward (the function tries to find the lowest possible port number ATTENTION: this part may introduce race conditions""" if useSSL is None: useSSL=config().getboolean("Network","SSLServerDefault") if useSSL: startPort=config().getint("Network","startServerPortSSL") else: startPort=config().getint("Network","startServerPort") return useSSL,freeServerPort(startPort, length=config().getint("Network","nrServerPorts"))
def findFreePort(useSSL=None): """Finds a free server port on this machine and returns it Valid server ports are in the range 18000 upward (the function tries to find the lowest possible port number ATTENTION: this part may introduce race conditions""" if useSSL is None: useSSL = config().getboolean("Network", "SSLServerDefault") if useSSL: startPort = config().getint("Network", "startServerPortSSL") else: startPort = config().getint("Network", "startServerPort") return useSSL, freeServerPort(startPort, length=config().getint( "Network", "nrServerPorts"))
from PyFoam.Infrastructure.NetworkHelpers import freeServerPort import socket firstport=1080 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind(('',firstport)) print "First Port between 1080 and 1180:",freeServerPort(firstport,length=100) sock.close()
from PyFoam.Infrastructure.NetworkHelpers import freeServerPort import socket firstport = 1080 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind(('', firstport)) print "First Port between 1080 and 1180:", freeServerPort(firstport, length=100) sock.close()