From 9f58705a39958a2a70adb05a5dab94168b5b0eed Mon Sep 17 00:00:00 2001 From: "bernard.xiong" Date: Fri, 26 Feb 2010 15:49:35 +0000 Subject: [PATCH] fix resolve host name issue git-svn-id: https://rt-thread.googlecode.com/svn/trunk@454 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/stm32_radio/http.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bsp/stm32_radio/http.c b/bsp/stm32_radio/http.c index 38ff38c4fb..7afb1b7d42 100644 --- a/bsp/stm32_radio/http.c +++ b/bsp/stm32_radio/http.c @@ -156,7 +156,7 @@ int http_resolve_address(struct sockaddr_in *server, const char * url, char *hos if (*url == ':') { unsigned char w; - for (w = 0; w < 5 && url[w] != '/' && url[w] != '\0'; w ++) + for (w = 0; w < 5 && url[w + 1] != '/' && url[w + 1] != '\0'; w ++) port[w] = url[w + 1]; /* get port ok */ @@ -165,6 +165,8 @@ int http_resolve_address(struct sockaddr_in *server, const char * url, char *hos break; } + if ((*url < '0' || *url > '9') && *url != '.') + is_domain = 1; host_addr[i++] = *url; url ++; } @@ -395,9 +397,9 @@ static int shoutcast_connect(struct shoutcast_session* session, buf = rt_malloc (512); if (*url) - length = rt_snprintf(buf, 512, _shoutcast_get, url, host_addr, server->sin_port); + length = rt_snprintf(buf, 512, _shoutcast_get, url, host_addr, ntohs(server->sin_port)); else - length = rt_snprintf(buf, 512, _shoutcast_get, "/", host_addr, server->sin_port); + length = rt_snprintf(buf, 512, _shoutcast_get, "/", host_addr, ntohs(server->sin_port)); rc = send(peer_handle, buf, length, 0); rt_kprintf("SHOUTCAST request:\n%s", buf); @@ -511,6 +513,8 @@ struct shoutcast_session* shoutcast_session_open(char* url) return RT_NULL; } + rt_kprintf("connect to: %s...\n", host_addr); + // Now we connect and initiate the transfer by sending a // request header to the server, and receiving the response header if((peer_handle = shoutcast_connect(session, &server, host_addr, request)) < 0) -- GitLab