Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sapi/cli/php_cli_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,16 @@ static php_socket_t php_network_listen_socket(const char *host, int *port, int s
setsockopt(retval, SOL_SOCKET, SO_REUSEADDR, (char*)&val, sizeof(val));
}
#endif
#ifdef SO_EXCLUSIVEADDRUSE
{
/**
* By default, windows allows multiple sockets to bind the same ip with the same port.
* SO_EXCLUSIVEADDRUSE prevents this while still allowing binding other different ip/port combinations.
**/
int val = 1;
setsockopt(retval, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*)&val, sizeof(val));
}
#endif

if (bind(retval, sa, *socklen) == SOCK_CONN_ERR) {
err = php_socket_errno();
Expand Down