[Cuis-dev] Cuis-dev Digest, Vol 67, Issue 44

Mark Volkmann r.mark.volkmann at gmail.com
Tue Oct 29 12:12:19 PDT 2024


Thanks for the feedback! I learned that with the WebServer class in the
WebClient package, once I have created an instance of WebServer I can do
the following to listen on an open port and get that port number:

server listenOn: 0.
port := server listenerSocket port

I changed the DogWebServerTests setup method in my WebClientPlus package to
use this approach.

On Tue, Oct 29, 2024 at 12:58 PM Jon Raiford via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:

> 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.
>
>
>
> Jon
>
>
>
> *From: *Cuis-dev <cuis-dev-bounces at lists.cuis.st> on behalf of r. clayton
> via Cuis-dev <cuis-dev at lists.cuis.st>
> *Date: *Tuesday, October 29, 2024 at 1:46 PM
> *To: *cuis-dev at lists.cuis.st <cuis-dev at lists.cuis.st>
> *Cc: *r. clayton <factotum at rclayton.org>
> *Subject: *Re: [Cuis-dev] Cuis-dev Digest, Vol 67, Issue 44
>
> openPort
> "Answer an open port number"
> | port socket |
>
> socket := Socket newTCP.
> socket listenOn: 0. "gets an ephemeral port"
> port := socket localPort.
> socket close.
> ^port.
>
> 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?
>
> 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).
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>


-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20241029/dd4a7d43/attachment.htm>


More information about the Cuis-dev mailing list