Made Luminotes Desktop try to default to a particular port number.
This commit is contained in:
parent
3da4f7e739
commit
6e693eaef3
3
NEWS
3
NEWS
|
@ -1,4 +1,7 @@
|
||||||
1.6.6: ?
|
1.6.6: ?
|
||||||
|
* Luminotes Desktop now attempts to always run on a particular port number,
|
||||||
|
which means that as long as it's running you can reach it from a constant
|
||||||
|
URL.
|
||||||
* Luminotes now recognizes "mailto:" links as external links, so you can
|
* Luminotes now recognizes "mailto:" links as external links, so you can
|
||||||
include links to email addresses within your notes.
|
include links to email addresses within your notes.
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,21 @@ username_postfix = os.environ.get( "USER" )
|
||||||
username_postfix = username_postfix and "_%s" % username_postfix or ""
|
username_postfix = username_postfix and "_%s" % username_postfix or ""
|
||||||
|
|
||||||
|
|
||||||
# find an available TCP socket to listen on
|
def find_available_port( port_number = 0 ):
|
||||||
sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
||||||
sock.bind( ( "", 0 ) )
|
sock.bind( ( "", port_number ) )
|
||||||
socket_port = sock.getsockname()[ 1 ]
|
socket_port = sock.getsockname()[ 1 ]
|
||||||
sock.close()
|
sock.close()
|
||||||
|
return socket_port
|
||||||
|
|
||||||
|
|
||||||
|
# find an available TCP socket to listen on. try the default port first, and if that's not
|
||||||
|
# available, then just grab any available port that the OS gives us
|
||||||
|
DEFAULT_PORT = 6520
|
||||||
|
try:
|
||||||
|
socket_port = find_available_port( DEFAULT_PORT )
|
||||||
|
except socket.error:
|
||||||
|
socket_port = find_available_port()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue