summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
fe9ab00)
If a connection to a host fails, print the port number in the brief error
message. This will hopefully eliminate problems when nmh is using a default
port number that users are not expecting.
if (res->ai_next)
snprintf(response, len_response, "no servers available (use -snoop "
"for details)");
if (res->ai_next)
snprintf(response, len_response, "no servers available (use -snoop "
"for details)");
- else
- snprintf(response, len_response, "Connection to \"%s\" failed: %s",
- server, strerror(errno));
+ else {
+ char port[NI_MAXSERV];
+
+ if (getnameinfo(res->ai_addr, res->ai_addrlen, NULL, 0, port,
+ sizeof port, NI_NUMERICSERV)) {
+ strncpy(port, "unknown", sizeof port);
+ port[sizeof(port) - 1] = '\0';
+ }
+
+ snprintf(response, len_response, "Connection to \"%s:%s\" failed: %s",
+ server, port, strerror(errno));
+ }