summaryrefslogtreecommitdiffstats
path: root/src/H5FDstream.h
diff options
context:
space:
mode:
authorThomas Radke <tradke@aei.mpg.de>2000-10-28 18:51:03 (GMT)
committerThomas Radke <tradke@aei.mpg.de>2000-10-28 18:51:03 (GMT)
commitf39c5d79852aaf2511849c5265e9ee3bc91d4fba (patch)
treeff4580ce55c68e194a15ac51d48f7582266c825a /src/H5FDstream.h
parent78365de55f2cf1859bcfbb4cfba486d3c9478760 (diff)
downloadhdf5-f39c5d79852aaf2511849c5265e9ee3bc91d4fba.zip
hdf5-f39c5d79852aaf2511849c5265e9ee3bc91d4fba.tar.gz
hdf5-f39c5d79852aaf2511849c5265e9ee3bc91d4fba.tar.bz2
[svn-r2746]
Purpose: Port to Windows platform Bug fix Description: The Stream VFD is ported to Windows now. Also fixed a bug where an application terminated when it got a SIGPIPE due to sending/receiving on a closed socket. Solution: The socket stuff is treated different under Windows when using the MS compilers to build HDF5. They define their own socket datatype and have closesocket() instead of close(2) to close sockets. Also there are different header files for all the socket stuff. So I introduced my own socket decriptor datatype in H5FDstream.h which should be used to pass in external sockets. This datatype is mapped to either 'int' (UNIX-type sockets) or 'SOCKET' (Windows). In the code the error code checking was adapted according to the socket datatype used. Also, for Windows you have to call a routine to initialize the Socket layer before using it. As a kind of bug fix, the process signal mask is now set to ignore SIGPIPE signals which otherwise cause the application to terminate. The driver read/write routines catch this and return an error code. Platforms tested: Windows NT, both with MS Visual C++ compiler and with GNU cc It is interesting that when compiling with GNU cc under Windows it is possible to use both Windows and UNIX-type sockets (either one or the other). So I check for GNU cc and go for UNIX sockets if possible.
Diffstat (limited to 'src/H5FDstream.h')
-rw-r--r--src/H5FDstream.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/H5FDstream.h b/src/H5FDstream.h
index c8acd65..aa0f339 100644
--- a/src/H5FDstream.h
+++ b/src/H5FDstream.h
@@ -7,30 +7,60 @@
* Tuesday, September 12, 2000
*
* Purpose: The public header file for the Stream Virtual File Driver.
+ *
+ * Version: $Header$
+ *
+ * Modifications:
+ * Thomas Radke, Thursday, October 26, 2000
+ * Added support for Windows.
+ *
*/
#ifndef H5FDstream_H
#define H5FDstream_H
#ifdef H5_HAVE_STREAM
+#include <H5pubconf.h>
#include <H5Ipublic.h>
-#ifdef __cplusplus
-extern "C" {
+/* check what sockets type we have (Unix or Windows sockets)
+ Note that only MS compilers require to use Windows sockets
+ but gcc under Windows does not. */
+#if ! defined(H5_HAVE_WINSOCK_H) || defined(__GNUC__)
+#define H5FD_STREAM_HAVE_UNIX_SOCKETS 1
+#endif
+
+/* define the data type for socket descriptors
+ and the constant indicating an invalid descriptor */
+#ifdef H5FD_STREAM_HAVE_UNIX_SOCKETS
+
+#define H5FD_STREAM_SOCKET_TYPE int
+#define H5FD_STREAM_INVALID_SOCKET -1
+
+#else
+#include <winsock.h>
+
+#define H5FD_STREAM_SOCKET_TYPE SOCKET
+#define H5FD_STREAM_INVALID_SOCKET SOCKET_ERROR
+
#endif
#define H5FD_STREAM (H5FD_stream_init())
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* prototype for read broadcast callback routine */
typedef int (*H5FD_stream_broadcast_t) (unsigned char **file,
haddr_t *len,
void *arg);
-/* Driver-specific file access properties */
+/* driver-specific file access properties */
typedef struct H5FD_stream_fapl_t
{
size_t increment; /* how much to grow memory in reallocs */
- int socket; /* external socket descriptor */
+ H5FD_STREAM_SOCKET_TYPE socket; /* external socket descriptor */
hbool_t do_socket_io; /* do I/O on socket */
unsigned int backlog; /* backlog argument for listen call */
H5FD_stream_broadcast_t broadcast_fn; /* READ broadcast callback */
@@ -38,6 +68,7 @@ typedef struct H5FD_stream_fapl_t
} H5FD_stream_fapl_t;
+/* prototypes of exported functions */
__DLL__ hid_t H5FD_stream_init (void);
__DLL__ herr_t H5Pset_fapl_stream (hid_t fapl_id,
H5FD_stream_fapl_t *fapl);