summaryrefslogtreecommitdiffstats
path: root/test/h5test.c
diff options
context:
space:
mode:
authorMuQun Yang <ymuqun@hdfgroup.org>2002-04-24 14:58:26 (GMT)
committerMuQun Yang <ymuqun@hdfgroup.org>2002-04-24 14:58:26 (GMT)
commit1da400ea6b5ac311bb65f807cc9920a7c1be7718 (patch)
tree18f7d7fee68680e7896d05aa3d0d713fa954b23c /test/h5test.c
parent6030317e1e23576e1e4ce308342a837fb0688a4d (diff)
downloadhdf5-1da400ea6b5ac311bb65f807cc9920a7c1be7718.zip
hdf5-1da400ea6b5ac311bb65f807cc9920a7c1be7718.tar.gz
hdf5-1da400ea6b5ac311bb65f807cc9920a7c1be7718.tar.bz2
[svn-r5245]
Purpose: windows support of socket function Description: gethostname is treated as socket function in windows and it is defined at winsock.h. for every windows socket function to be called, it must start with WSAStartup and end with WSACleanup Solution: Add WSAstartup and WSACleanup with WIN32 macro. Platforms tested: windows 2000, confirmed at linux 2.2.18
Diffstat (limited to 'test/h5test.c')
-rw-r--r--test/h5test.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/h5test.c b/test/h5test.c
index e0c46a6..05d5147 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -17,6 +17,7 @@
#ifdef WIN32
#include <process.h>
#include <direct.h>
+#include <winsock.h>
#endif /* WIN32 */
/*
@@ -523,6 +524,10 @@ void
h5_show_hostname(void)
{
char hostname[80];
+#ifdef WIN32
+ WSADATA wsaData;
+ int err;
+#endif
/* try show the process or thread id in multiple processes cases*/
#ifdef H5_HAVE_PARALLEL
@@ -541,9 +546,35 @@ h5_show_hostname(void)
#else
printf("thread 0.");
#endif
+#ifdef WIN32
+
+ err = WSAStartup( MAKEWORD(2,2), &wsaData );
+ if ( err != 0 ) {
+ /* could not find a usable WinSock DLL */
+ return;
+ }
+
+/* Confirm that the WinSock DLL supports 2.2.*/
+/* Note that if the DLL supports versions greater */
+/* than 2.2 in addition to 2.2, it will still return */
+/* 2.2 in wVersion since that is the version we */
+/* requested. */
+
+ if ( LOBYTE( wsaData.wVersion ) != 2 ||
+ HIBYTE( wsaData.wVersion ) != 2 ) {
+ /* could not find a usable WinSock DLL */
+ WSACleanup( );
+ return;
+ }
+
+#endif
+
if (gethostname(hostname, 80) < 0){
printf(" gethostname failed\n");
}
else
printf(" hostname=%s\n", hostname);
+#ifdef WIN32
+ WSACleanup();
+#endif
}