protoc-bridge icon indicating copy to clipboard operation
protoc-bridge copied to clipboard

Fix getting a free socket on macos

Open reimai opened this issue 9 months ago • 1 comments

Here is a new fix for a free socket on mac problem, without restry. Turns out mac allows a socket on ANY host (. in netstat) to bind even though a socket with localhost and a same port is present in LISTENING state. This is different from linux, where such an attempt would fail with a java.net.BindException.

A way to fix this is by simply passing a localhost (or rather 127.0.0.1, to match MacPluginFrontend) to ServerSocket constructor. I've test it on my project, and got no failures on 5 rebuilds (it used to be 2 failed bazel targets per rebuild on protoc-bridge:0.9.8).

reimai avatar Mar 25 '25 14:03 reimai

@bell-db fyi

thesamet avatar Mar 25 '25 14:03 thesamet