Connect to winehq.org by its name rather than by its IP addr.
This commit is contained in:
parent
dbcc37ba7d
commit
d89279a974
|
@ -24,20 +24,30 @@
|
||||||
#include "winetest.h"
|
#include "winetest.h"
|
||||||
|
|
||||||
SOCKET
|
SOCKET
|
||||||
open_http (const char *ipnum)
|
open_http (const char *server)
|
||||||
{
|
{
|
||||||
WSADATA wsad;
|
WSADATA wsad;
|
||||||
struct sockaddr_in sa;
|
struct sockaddr_in sa;
|
||||||
SOCKET s;
|
SOCKET s;
|
||||||
|
|
||||||
report (R_STATUS, "Opening HTTP connection to %s", ipnum);
|
report (R_STATUS, "Opening HTTP connection to %s", server);
|
||||||
if (WSAStartup (MAKEWORD (2,2), &wsad)) return INVALID_SOCKET;
|
if (WSAStartup (MAKEWORD (2,2), &wsad)) return INVALID_SOCKET;
|
||||||
|
|
||||||
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (s != INVALID_SOCKET) {
|
if (s != INVALID_SOCKET) {
|
||||||
|
unsigned long addr = inet_addr(server);
|
||||||
|
|
||||||
sa.sin_family = AF_INET;
|
sa.sin_family = AF_INET;
|
||||||
sa.sin_port = htons (80);
|
sa.sin_port = htons (80);
|
||||||
sa.sin_addr.s_addr = inet_addr (ipnum);
|
if (addr != INADDR_NONE)
|
||||||
|
sa.sin_addr.s_addr = addr;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct hostent *host;
|
||||||
|
|
||||||
|
if ((host = gethostbyname(server)) != NULL)
|
||||||
|
addr = ((struct in_addr *)host->h_addr)->s_addr;
|
||||||
|
}
|
||||||
if (!connect (s, (struct sockaddr*)&sa,
|
if (!connect (s, (struct sockaddr*)&sa,
|
||||||
sizeof (struct sockaddr_in)))
|
sizeof (struct sockaddr_in)))
|
||||||
return s;
|
return s;
|
||||||
|
@ -113,7 +123,7 @@ send_file (const char *name)
|
||||||
"--" SEP "--\r\n";
|
"--" SEP "--\r\n";
|
||||||
|
|
||||||
buffer = xmalloc (BUFLEN + 1);
|
buffer = xmalloc (BUFLEN + 1);
|
||||||
s = open_http ("198.144.15.226");
|
s = open_http ("www.winehq.org");
|
||||||
if (s == INVALID_SOCKET) {
|
if (s == INVALID_SOCKET) {
|
||||||
report (R_WARNING, "Can't open network connection: %d",
|
report (R_WARNING, "Can't open network connection: %d",
|
||||||
WSAGetLastError ());
|
WSAGetLastError ());
|
||||||
|
|
Loading…
Reference in New Issue