diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-09-10 08:47:19 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-09-10 08:47:19 +0200 |
commit | b6c9d9a880f6f1a6908a3c62dfccdce3e68dad80 (patch) | |
tree | d3e9e9340064538a8dc7a645260d0eb3cdf55d63 /cpp/src/Ice/StreamSocket.h | |
parent | Undo bogus change from an earlier commit. (diff) | |
download | ice-b6c9d9a880f6f1a6908a3c62dfccdce3e68dad80.tar.bz2 ice-b6c9d9a880f6f1a6908a3c62dfccdce3e68dad80.tar.xz ice-b6c9d9a880f6f1a6908a3c62dfccdce3e68dad80.zip |
ICE-5582 (SOCKs test), ICE-5314 (HTTP proxies), major refactoring of networking code (addition of StreamSocket class abstraction)
Diffstat (limited to 'cpp/src/Ice/StreamSocket.h')
-rw-r--r-- | cpp/src/Ice/StreamSocket.h | 85 |
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 + |