<div dir="ltr">Thanks for the feedback! I learned that with the <font face="monospace">WebServer</font> class in the <font face="monospace">WebClient</font> package, once I have created an instance of <font face="monospace">WebServer</font> I can do the following to listen on an open port and get that port number:<div><br></div><div><font face="monospace">server listenOn: 0.<br>port := server listenerSocket port</font><br></div><div><font face="monospace"><br></font></div><div><font face="arial, sans-serif">I changed the </font><font face="monospace">DogWebServerTests setup</font><font face="arial, sans-serif"> method in my </font><font face="monospace">WebClientPlus</font><font face="arial, sans-serif"> package to use this approach.</font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 29, 2024 at 12:58 PM Jon Raiford via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div class="msg5758444943232403041">
<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="m_5758444943232403041WordSection1">
<p class="MsoNormal"><span style="font-size:11pt">Yes, that is certainly a race condition waiting to happen. I believe “open” here is acting as an adjective and not a verb, as in, I’ll answer a port that happens to be open (available) right now. I’m not sure
what the benefit is though. If you just want to listen on a random port that is guaranteed to be available then set the port to zero at the time you call listenOn: and don’t close the port until you are done with it.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt">Jon<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<div id="m_5758444943232403041mail-editor-reference-message-container">
<div>
<div>
<div style="border-width:1pt medium medium;border-style:solid none none;border-color:rgb(181,196,223) currentcolor currentcolor;padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="color:black">From:
</span></b><span style="color:black">Cuis-dev <<a href="mailto:cuis-dev-bounces@lists.cuis.st" target="_blank">cuis-dev-bounces@lists.cuis.st</a>> on behalf of r. clayton via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>><br>
<b>Date: </b>Tuesday, October 29, 2024 at 1:46</span><span style="font-family:Arial,sans-serif;color:black"> </span><span style="color:black">PM<br>
<b>To: </b><a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a> <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>><br>
<b>Cc: </b>r. clayton <<a href="mailto:factotum@rclayton.org" target="_blank">factotum@rclayton.org</a>><br>
<b>Subject: </b>Re: [Cuis-dev] Cuis-dev Digest, Vol 67, Issue 44<u></u><u></u></span></p>
</div>
<p class="MsoNormal">openPort<br>
"Answer an open port number"<br>
| port socket |<br>
<br>
socket := Socket newTCP.<br>
socket listenOn: 0. "gets an ephemeral port"<br>
port := socket localPort.<br>
socket close.<br>
^port.<br>
<br>
Forgive me for asking a possibly dumb question, but how is this not a race condition waiting to happen? Ports are a system-wide resource (considering ports above 1023). What prevents a process elsewhere on the system, not necessarily within Cuis, from allocating
the port returned by openPort?<br>
<br>
Also, since I'm being picky, "open" is probably not the best choice of words if I'm correctly understanding the code's intention. Despite being in the vernacular, "open" doesn't doesn't necessarily mean "available" or "unallocated." You could argue that "open"
means "unavailable" and "allocated" (consider TCP to make this argument clear).<br>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="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.8px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div>