<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">>> +// port to try to listen on, if we can't, increment until we find one we can<br>

>> +const int PORT_RANGE_START = 5600;<br>
>><br>
> Since server default is 5900, does this mean we always increment though<br>
> 400 ports?<br>
</div>No, this is the start of the range for the tunnel port which the viewer<br>
opens on your local machine. When the user clicks a vm name,<br>
ovirt-viewer connects to this local port, which accepts vnc data,<br>
prepending the target vm name, and sends it onto port 5900 on the<br>
server. Since this port is going to be opened on the client's machine,<br>
we don't know which ports are available ahead of time, so I start trying<br>
to open ports at 5600 and increment until we found one that's available.<br></blockquote></div><br>Why not just use random port by setting sin_port=0 ?<br>Patch attached, untested.<br><br>