summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/StreamSocket.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/StreamSocket.h')
-rw-r--r--cpp/src/Ice/StreamSocket.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/cpp/src/Ice/StreamSocket.h b/cpp/src/Ice/StreamSocket.h
new file mode 100644
index 00000000000..7a872599944
--- /dev/null
+++ b/cpp/src/Ice/StreamSocket.h
@@ -0,0 +1,85 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef ICE_STREAM_SOCKET_H
+#define ICE_STREAM_SOCKET_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/Network.h>
+#include <Ice/Buffer.h>
+#include <Ice/ProtocolInstanceF.h>
+
+namespace IceInternal
+{
+
+class ICE_API StreamSocket : public NativeInfo
+{
+public:
+
+ StreamSocket(const ProtocolInstancePtr&, const NetworkProxyPtr&, const Address&, const Address&);
+ StreamSocket(const ProtocolInstancePtr&, SOCKET);
+ virtual ~StreamSocket();
+
+ SocketOperation connect(Buffer&, Buffer&);
+ bool isConnected();
+ size_t getSendPacketSize(size_t);
+ size_t getRecvPacketSize(size_t);
+
+ SocketOperation read(Buffer&);
+ SocketOperation write(Buffer&);
+
+ ssize_t read(char*, size_t);
+ ssize_t write(const char*, size_t);
+
+#ifdef ICE_USE_IOCP
+ AsyncInfo* getAsyncInfo(SocketOperation);
+ bool startWrite(Buffer&);
+ void finishWrite(Buffer&);
+ void startRead(Buffer&);
+ void finishRead(Buffer&);
+#endif
+
+ void close();
+ const std::string& toString() const;
+
+private:
+
+ void init(const ProtocolInstancePtr&);
+
+ enum State
+ {
+ StateNeedConnect,
+ StateConnectPending,
+ StateProxyWrite,
+ StateProxyRead,
+ StateProxyConnected,
+ StateConnected
+ };
+ State toState(SocketOperation) const;
+
+ const NetworkProxyPtr _proxy;
+ const Address _addr;
+ const Address _sourceAddr;
+
+ State _state;
+ std::string _desc;
+
+#ifdef ICE_USE_IOCP
+ size_t _maxSendPacketSize;
+ size_t _maxRecvPacketSize;
+ AsyncInfo _read;
+ AsyncInfo _write;
+#endif
+};
+typedef IceUtil::Handle<StreamSocket> StreamSocketPtr;
+
+}
+
+#endif
+