aboutsummaryrefslogtreecommitdiff
path: root/core/net/errors_darwin.odin
diff options
context:
space:
mode:
authorTetralux <tetraluxonpc@gmail.com>2024-02-22 14:41:37 +0000
committerTetralux <tetraluxonpc@gmail.com>2024-02-22 14:55:27 +0000
commitec0831da706f696ce6b65e3ac2108179902f0d38 (patch)
treecb6eefe988358b206c8d2f2355218198f17e03fa /core/net/errors_darwin.odin
parentc5c2a4d09d98f0d3b6263e204785553e47b83395 (diff)
[net] Better error code for binding a privileged port without root access on Darwin
This condition results in os.EACCESS, which we were translating to Broadcast_Disabled. This was the case because binding to the broadcast address on a UDP port, without setting the BROADCAST flag, also results in this error. Given the fact that reserved ports also produce this error, we now check for this condition in net.bind() and translate it to a custom, clearer error: Privileged_Port_Without_Root.
Diffstat (limited to 'core/net/errors_darwin.odin')
-rw-r--r--core/net/errors_darwin.odin6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/net/errors_darwin.odin b/core/net/errors_darwin.odin
index c80d2cf56..3116af0ab 100644
--- a/core/net/errors_darwin.odin
+++ b/core/net/errors_darwin.odin
@@ -34,7 +34,7 @@ Create_Socket_Error :: enum c.int {
Dial_Error :: enum c.int {
None = 0,
- Port_Required = -1,
+ Port_Required = -1, // Attempted to dial an endpointing without a port being set.
Address_In_Use = c.int(os.EADDRINUSE),
In_Progress = c.int(os.EINPROGRESS),
@@ -54,7 +54,9 @@ Dial_Error :: enum c.int {
}
Bind_Error :: enum c.int {
- None = 0,
+ None = 0,
+ Privileged_Port_Without_Root = -1, // Attempted to bind to a port less than 1024 without root access.
+
Address_In_Use = c.int(os.EADDRINUSE), // Another application is currently bound to this endpoint.
Given_Nonlocal_Address = c.int(os.EADDRNOTAVAIL), // The address is not a local address on this machine.
Broadcast_Disabled = c.int(os.EACCES), // To bind a UDP socket to the broadcast address, the appropriate socket option must be set.