Open dgelessus opened 2 years ago
I see. In fact, using Wine I get something different: tcp_connect/3 with just a port succeeds, with '':Port
raises an exception and using localhost:Port
works fine too. I've pushed a patch to initialize the complete address info. No idea how that will work out on the various platforms. It can't be bad to avoid using uninitialized memory though :smile:
An odd OS difference. On Unix (macOS and Linux), one can pass just a port number as the
Address
intotcp_connect
to connect to a local port. On Windows, the same call gives an error, so one has to explicitly pass'':Port
orlocalhost:Port
instead.According to the docs,
tcp_connect/3
actually requires an explicit hostname and shouldn't accept a plain port:So the fix would be either to document the Unix behavior and support plain port numbers on Windows as well, or to check and disallow plain port numbers on all platforms. I would vote for the first option, because it avoids breaking existing code - and would also match what SICStus'
library(sockets)
does 🙂