Skip to content

Commit

Permalink
[452927] Fix bind()/listen() error reporting on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Jan 28, 2015
1 parent 1b4903b commit 8eda59c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,19 @@ int mqtt3_socket_listen(struct _mqtt3_listener *listener)
}

if(bind(sock, rp->ai_addr, rp->ai_addrlen) == -1){
#ifdef WIN32
errno = WSAGetLastError();
#endif
strerror_r(errno, buf, 256);
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: %s", buf);
COMPAT_CLOSE(sock);
return 1;
}

if(listen(sock, 100) == -1){
#ifdef WIN32
errno = WSAGetLastError();
#endif
strerror_r(errno, buf, 256);
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: %s", buf);
COMPAT_CLOSE(sock);
Expand Down

0 comments on commit 8eda59c

Please sign in to comment.