On 30 Jan 2017, at 21:13 , Denis Kudriashov <dionisiydk@gmail.com> wrote:


2017-01-30 20:25 GMT+01:00 Sven Van Caekenberghe <sven@stfx.eu>:
Well, you should do your utmost best to prevent the situation in the first place (use startup/shutdown behaviour correctly).

I remember I had those problems a lot in the beginning of Zn, especially when running tests that sometimes failed.

Have you seen Zn's #isListening ? I think that was written to catch the case you described, but I am not sure it is 100% rock solid.

Yes. This is exactly how I fix my case.
But this post is about general problem which I think is very critical.

In #isListening code I see extra condition  "self serverSocket localPort = self port". Could you explain what case it is covered?  


Doesn't work on Windows;
https://pharo.fogbugz.com/f/cases/16939/Intermittent-monkey-failures-due-to-port-usage-in-server-tests

IIRC, behaviour is different on all three platforms:
- Linux raises error
- Mac assigns different port than requested
- Win assigns requested port, but receives no traffic.

How to detect the last one from image is a very good question (tm) indeed... 

Cheers,
Henry