<div dir="ltr">I wrote the following code to take a port number and return the first port starting from that number that is open. For example, if ports 3000 and 3001 are in use and I send "MyClass openPortFrom: 3000" then I expect it to return 3002. Can you spot why this never finds an open port and loops forever?<div><br></div><div><font face="monospace">openPortFrom: aNumber<br>    | connected port socket |<br>        <br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">connected := false.<br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">port := aNumber.<br> <br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">[ connected ] whileFalse: [<br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">'trying port {1}' format: { port } :: print.</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">socket := Socket newTCP.</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">socket listenOn: port.</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">connected := socket waitForConnectionFor: 1 ifTimedOut: [ false ].</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">connected ifTrue: [socket disconnect] ifFalse: [ port := port + 1 ].</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><font face="monospace">].<br><br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">^port.</font><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">R. Mark Volkmann</font></div><div><span style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div></div></div>