diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-06-07 17:01:30 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-06-07 17:01:30 +0000 |
commit | a737fcdae3a825d1a3df353a08df3c12285cde43 (patch) | |
tree | ce5c2f7aed6194cb4d94cb07e00b7380bc320e7b /cpp/src/Ice/UdpConnector.cpp | |
parent | Added missing IComparable (diff) | |
download | ice-a737fcdae3a825d1a3df353a08df3c12285cde43.tar.bz2 ice-a737fcdae3a825d1a3df353a08df3c12285cde43.tar.xz ice-a737fcdae3a825d1a3df353a08df3c12285cde43.zip |
More changes for bug 1996
Diffstat (limited to 'cpp/src/Ice/UdpConnector.cpp')
-rw-r--r-- | cpp/src/Ice/UdpConnector.cpp | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/cpp/src/Ice/UdpConnector.cpp b/cpp/src/Ice/UdpConnector.cpp new file mode 100644 index 00000000000..f8607b5627a --- /dev/null +++ b/cpp/src/Ice/UdpConnector.cpp @@ -0,0 +1,188 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#include <Ice/UdpConnector.h> +#include <Ice/UdpTransceiver.h> +#include <Ice/UdpEndpointI.h> +#include <Ice/Network.h> + +using namespace std; +using namespace Ice; +using namespace IceInternal; + +TransceiverPtr +IceInternal::UdpConnector::connect(int timeout) +{ + return new UdpTransceiver(_instance, _addr, _mcastInterface, _mcastTtl); +} + +Short +IceInternal::UdpConnector::type() const +{ + return UdpEndpointType; +} + +string +IceInternal::UdpConnector::toString() const +{ + return addrToString(_addr); +} + +bool +IceInternal::UdpConnector::operator==(const Connector& r) const +{ + const UdpConnector* p = dynamic_cast<const UdpConnector*>(&r); + if(!p) + { + return false; + } + + if(compareAddress(_addr, p->_addr) != 0) + { + return false; + } + + if(_connectionId != p->_connectionId) + { + return false; + } + + if(_protocolMajor != p->_protocolMajor) + { + return false; + } + + if(_protocolMinor != p->_protocolMinor) + { + return false; + } + + if(_encodingMajor != p->_encodingMajor) + { + return false; + } + + if(_encodingMinor != p->_encodingMinor) + { + return false; + } + + if(_mcastTtl != p->_mcastTtl) + { + return false; + } + + if(_mcastInterface != p->_mcastInterface) + { + return false; + } + + return true; +} + +bool +IceInternal::UdpConnector::operator!=(const Connector& r) const +{ + return !operator==(r); +} + +bool +IceInternal::UdpConnector::operator<(const Connector& r) const +{ + const UdpConnector* p = dynamic_cast<const UdpConnector*>(&r); + if(!p) + { + return type() < r.type(); + } + + if(_connectionId < p->_connectionId) + { + return true; + } + else if(p->_connectionId < _connectionId) + { + return false; + } + + if(_protocolMajor < p->_protocolMajor) + { + return true; + } + else if(p->_protocolMajor < _protocolMajor) + { + return false; + } + + if(_protocolMinor < p->_protocolMinor) + { + return true; + } + else if(p->_protocolMinor < _protocolMinor) + { + return false; + } + + if(_encodingMajor < p->_encodingMajor) + { + return true; + } + else if(p->_encodingMajor < _encodingMajor) + { + return false; + } + + if(_encodingMinor < p->_encodingMinor) + { + return true; + } + else if(p->_encodingMinor < _encodingMinor) + { + return false; + } + + if(_mcastTtl < p->_mcastTtl) + { + return true; + } + else if(p->_mcastTtl < _mcastTtl) + { + return false; + } + + if(_mcastInterface < p->_mcastInterface) + { + return true; + } + else if(p->_mcastInterface < _mcastInterface) + { + return false; + } + + return compareAddress(_addr, p->_addr) == -1; +} + +IceInternal::UdpConnector::UdpConnector(const InstancePtr& instance, const struct sockaddr_in& addr, + const string& mcastInterface, int mcastTtl, Ice::Byte protocolMajor, + Ice::Byte protocolMinor, Ice::Byte encodingMajor, Ice::Byte encodingMinor, + const std::string& connectionId) : + _instance(instance), + _addr(addr), + _mcastInterface(mcastInterface), + _mcastTtl(mcastTtl), + _protocolMajor(protocolMajor), + _protocolMinor(protocolMinor), + _encodingMajor(encodingMajor), + _encodingMinor(encodingMinor), + _connectionId(connectionId) +{ +} + +IceInternal::UdpConnector::~UdpConnector() +{ +} |