summaryrefslogtreecommitdiff
path: root/test/client-server/socket_wrapper.h
diff options
context:
space:
mode:
authorJason Maskell <[email protected]>2016-05-09 10:39:54 +0200
committerJason Maskell <[email protected]>2016-05-09 10:39:54 +0200
commit79b3462799c28af8ba586349bd671b1b56e72353 (patch)
tree3b06e36c390254c0dc7f3733a0d32af213d87293 /test/client-server/socket_wrapper.h
downloadwaveworks_archive-79b3462799c28af8ba586349bd671b1b56e72353.tar.xz
waveworks_archive-79b3462799c28af8ba586349bd671b1b56e72353.zip
Initial commit with PS4 and XBone stuff trimmed.
Diffstat (limited to 'test/client-server/socket_wrapper.h')
-rw-r--r--test/client-server/socket_wrapper.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/test/client-server/socket_wrapper.h b/test/client-server/socket_wrapper.h
new file mode 100644
index 0000000..a18e679
--- /dev/null
+++ b/test/client-server/socket_wrapper.h
@@ -0,0 +1,106 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved.
+//
+// NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+// rights in and to this software and related documentation and any modifications thereto.
+// Any use, reproduction, disclosure or distribution of this software and related
+// documentation without an express license agreement from NVIDIA Corporation is
+// strictly prohibited.
+//
+
+#ifndef _SOCKET_WRAPPER_H
+#define _SOCKET_WRAPPER_H
+
+struct SocketWrapperImpl;
+
+#if defined(__linux__ ) || defined(__ORBIS__)
+typedef int SOCKET_TYPE;
+#else
+typedef int socklen_t;
+#if defined(_WIN64)
+ typedef unsigned __int64 SOCKET_TYPE;
+#else
+ typedef unsigned int SOCKET_TYPE;
+#endif
+#endif
+
+int init_networking();
+int term_networking();
+int set_non_blocking(SOCKET_TYPE s);
+bool wouldblock();
+
+/*********************************************************************************
+ Super-simple wrapper class for doing send/receive on non-blocking sockets
+*********************************************************************************/
+class SocketWrapper
+{
+public:
+
+ SocketWrapper(SOCKET_TYPE platformSocket);
+ ~SocketWrapper();
+
+ bool is_usable() const;
+
+ void enqueue_send_message(void* msgData, unsigned int msgLength);
+
+ bool has_recv_message() const;
+ unsigned int recv_message_length() const;
+ void* recv_message() const;
+ void consume_recv_message();
+
+ enum PumpResult
+ {
+ PumpResult_NoTraffic = 0, // The internal send/recv queues are both empty, and there was no new traffic on this pump
+ PumpResult_Traffic,
+ PumpResult_Error
+ };
+
+ PumpResult pump();
+
+private:
+
+ SocketWrapperImpl* pImpl;
+};
+
+/*********************************************************************************
+ Misc x-plat helpers...
+*********************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////////
+#if defined(__linux__) || defined(__ORBIS__)
+////////////////////////////////////////////////////////////////////////////////
+#define closesocket close
+#define INVALID_SOCKET (-1)
+////////////////////////////////////////////////////////////////////////////////
+#endif
+////////////////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////////////
+#if defined(__ORBIS__)
+////////////////////////////////////////////////////////////////////////////////
+int gethostname(char* buff, int buffsize);
+#define SOMAXCONN 128
+////////////////////////////////////////////////////////////////////////////////
+#endif
+////////////////////////////////////////////////////////////////////////////////
+
+#endif // _MESSAGETYPES_H