4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-18 13:13:31 +08:00

fix resolve host name issue

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@454 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong 2010-02-26 15:49:35 +00:00
parent 03d17809b7
commit 9f58705a39

View File

@ -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)