Juan Lang : wininet: Create a TCP connection if FLAG_ICC_FORCE_CONNECTION is specified.
Alexandre Julliard
julliard at winehq.org
Tue Sep 18 05:31:06 CDT 2007
Module: wine
Branch: master
Commit: ba45902dafc8fabd93ce49e2d8bcf4cc9d946e33
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ba45902dafc8fabd93ce49e2d8bcf4cc9d946e33
Author: Juan Lang <juan.lang at gmail.com>
Date: Mon Sep 17 08:40:04 2007 -0700
wininet: Create a TCP connection if FLAG_ICC_FORCE_CONNECTION is specified.
---
dlls/wininet/internet.c | 49 +++++++++++++++++++++++++++++++++-------------
1 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 9910955..345b2aa 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -2739,6 +2739,7 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe
CHAR *command = NULL;
WCHAR hostW[1024];
DWORD len;
+ INTERNET_PORT port;
int status = -1;
FIXME("\n");
@@ -2770,26 +2771,46 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe
goto End;
TRACE("host name : %s\n",debugstr_w(components.lpszHostName));
+ port = components.nPort;
+ TRACE("port: %d\n", port);
}
- /*
- * Build our ping command
- */
- len = WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, NULL, 0, NULL, NULL);
- command = HeapAlloc( GetProcessHeap(), 0, strlen(ping)+len+strlen(redirect) );
- strcpy(command,ping);
- WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, command+strlen(ping), len, NULL, NULL);
- strcat(command,redirect);
+ if (dwFlags & FLAG_ICC_FORCE_CONNECTION)
+ {
+ struct sockaddr_in sin;
+ int fd;
+
+ if (!GetAddress(hostW, port, &sin))
+ goto End;
+ fd = socket(sin.sin_family, SOCK_STREAM, 0);
+ if (fd != -1)
+ {
+ if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == 0)
+ rc = TRUE;
+ close(fd);
+ }
+ }
+ else
+ {
+ /*
+ * Build our ping command
+ */
+ len = WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, NULL, 0, NULL, NULL);
+ command = HeapAlloc( GetProcessHeap(), 0, strlen(ping)+len+strlen(redirect) );
+ strcpy(command,ping);
+ WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, command+strlen(ping), len, NULL, NULL);
+ strcat(command,redirect);
- TRACE("Ping command is : %s\n",command);
+ TRACE("Ping command is : %s\n",command);
- status = system(command);
+ status = system(command);
- TRACE("Ping returned a code of %i\n",status);
+ TRACE("Ping returned a code of %i\n",status);
- /* Ping return code of 0 indicates success */
- if (status == 0)
- rc = TRUE;
+ /* Ping return code of 0 indicates success */
+ if (status == 0)
+ rc = TRUE;
+ }
End:
More information about the wine-cvs
mailing list