I'm writing some critical code and need at one point to establish a TCP connection using connect()
.
I dig into POSIX manpages to ensure that my code is fully POSIX compliant, and have to write unit tests covering all possible error cases.
Considering this document, I fail to understand what the following means:
EADDRINUSE Attempt to establish a connection that uses addresses that are already in use.
At first sight I thought I could be triggered by the lack of ephemeral port, but this error is reported by EADDRNOTAVAIL
(which I successfully triggered in an unit test).
Concretely, what does it mean? Which condition could lead to this error? I understand the semantic for this error on bind()
, but how could connect()
raise that?
My feeling, though this is guesswork, is that this error is for non-TCP sockets, specifically unix sockets - AF_UNIX (also known as AF_LOCAL)
The linux connect() mangpage puts it just slightly differently than the one you linked:
EADDRINUSE Local address is already in use.
The usage of the word "Local" led me to the unix
manpage which states
EADDRINUSE The specified local address is already in use or the filesystem socket object already exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With