Check-in [83455d7349]
Not logged in
Overview
Comment:Replaced find_free_port with more generic version
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 83455d7349371eb0e1df3e420276598575c4c302
User & Date: vitus on 2017-01-14 11:15:49
Other Links: manifest | tags
Context
2017-01-14
15:33
Don't try to start spice client if DISPLAY env var doesn't present check-in: 7a641a0a0e user: vitus tags: trunk
11:15
Replaced find_free_port with more generic version check-in: 83455d7349 user: vitus tags: trunk
07:08
Make spiceuri report FQDN if spice socket is bound to all addresses. Fixes [b186056b7771] check-in: efefe8ac53 user: vitus tags: trunk
Changes

Modified find_free_port from [97bc56ed90] to [6153a27ecd].

1
2

3
4
5

6
7
8
9
10
11










12
13
14
15
16


17
18

19
20
21



1

2

3

4
5





6
7
8
9
10
11
12
13
14
15





16
17


18
19


20
21
22

-
+
-

-
+

-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
-
-
+

-
-
+
+
+
#!/usr/bin/python
import os,sys,re
import sys,socket,errno
f=os.popen("netstat -nlt4","r")
if len(sys.argv)>1:
	start=int(sys.argv[1])
	port=int(sys.argv[1])
else:
	start=5900
s=set()
for line in f:
    if not line.startswith("tcp"):
        continue
	port=5900
    
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
while True:
    try:
        s.bind(("",port))
    except socket.error as e:
        if e.errno== errno.EADDRINUSE:
            port+=1
            continue
    m=re.search(":(\\d+)\\b",line)
    if m:
        s.add(int(m.group(1)))
i=start
while i in s:
        else:
            raise e
    i += 1
print i
    break

        

s.close()
print port