include: clarify uv_tcp_bind() behavior

On BSD-like platforms, EADDRINUSE is returned by the bind() system call.
On other platforms, it's returned by the listen() system call.

In other words, some platforms are 'first to bind wins', others are
'first to listen wins' - but only with TCP sockets: UNIX domain sockets
always return EADDRINUSE from the bind() system call, UDP sockets don't
call listen() in the first place.

Fixes #769.
This commit is contained in:
Ben Noordhuis 2013-09-06 14:53:04 +02:00
parent 2b9c374c1c
commit 02e8c8ef65

View File

@ -769,6 +769,12 @@ UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable);
/*
* Bind the handle to an address and port. `addr` should point to an
* initialized struct sockaddr_in or struct sockaddr_in6.
*
* When the port is already taken, you can expect to see an UV_EADDRINUSE
* error from either uv_tcp_bind(), uv_listen() or uv_tcp_connect().
*
* That is, a successful call to uv_tcp_bind() does not guarantee that
* the call to uv_listen() or uv_tcp_connect() will succeed as well.
*/
UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr* addr);