diff options
author | Gisle Vanem <gvanem@broadpark.no> | 2005-09-06 15:43:14 +0000 |
---|---|---|
committer | Gisle Vanem <gvanem@broadpark.no> | 2005-09-06 15:43:14 +0000 |
commit | 9e38d882b9bb3a63bd464ed2ea83a045d52a8db2 (patch) | |
tree | bb4f0397ca274337c4625f7cddcf42136eb473cd | |
parent | e8635044b58ff0fb93465758e70867428bd4cc1b (diff) |
Fix for bind() on Winsock; AF_UNSPEC (0) is illegal.
Should we do this for all targets?
-rw-r--r-- | lib/tftp.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/tftp.c b/lib/tftp.c index 4cdbdc22e..37e91b310 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -73,6 +73,8 @@ #include "sendf.h" #include "tftp.h" #include "progress.h" +#include "connect.h" +#include "strerror.h" #define _MPRINTF_REPLACE /* use our functions only */ #include <curl/mprintf.h> @@ -533,12 +535,18 @@ CURLcode Curl_tftp_connect(struct connectdata *conn, bool *done) state->sockfd = state->conn->sock[FIRSTSOCKET]; state->state = TFTP_STATE_START; +#ifdef WIN32 + /* AF_UNSPEC == 0 (from above calloc) doesn't work on Winsock */ + state->local_addr.sa_family = conn->ip_addr->ai_family; +#endif + tftp_set_timeouts(state); /* Bind to any interface, random UDP port */ rc = bind(state->sockfd, &state->local_addr, sizeof(state->local_addr)); if(rc) { - failf(conn->data, "failed to bind\n"); + failf(conn->data, "bind() failed; %s\n", + Curl_strerror(conn,Curl_ourerrno())); return CURLE_COULDNT_CONNECT; } |