summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/TcpEndpointI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/TcpEndpointI.cpp')
-rw-r--r--cpp/src/Ice/TcpEndpointI.cpp352
1 files changed, 176 insertions, 176 deletions
diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp
index 817008a0141..6cf54872826 100644
--- a/cpp/src/Ice/TcpEndpointI.cpp
+++ b/cpp/src/Ice/TcpEndpointI.cpp
@@ -22,7 +22,7 @@ using namespace Ice;
using namespace IceInternal;
IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti,
- const string& conId, bool co, bool pub) :
+ const string& conId, bool co, bool pub) :
_instance(instance),
_host(ho),
_port(po),
@@ -47,96 +47,96 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin
while(true)
{
- beg = str.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
-
- string option = str.substr(beg, end - beg);
- if(option.length() != 2 || option[0] != '-')
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
-
- string argument;
- string::size_type argumentBeg = str.find_first_not_of(delim, end);
- if(argumentBeg != string::npos && str[argumentBeg] != '-')
- {
- beg = argumentBeg;
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
- argument = str.substr(beg, end - beg);
- }
-
- switch(option[1])
- {
- case 'h':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- const_cast<string&>(_host) = argument;
- break;
- }
-
- case 'p':
- {
- istringstream p(argument);
- if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- break;
- }
-
- case 't':
- {
- istringstream t(argument);
- if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- break;
- }
-
- case 'z':
- {
- if(!argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- const_cast<bool&>(_compress) = true;
- break;
- }
-
- default:
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- }
+ beg = str.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+
+ string option = str.substr(beg, end - beg);
+ if(option.length() != 2 || option[0] != '-')
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+
+ string argument;
+ string::size_type argumentBeg = str.find_first_not_of(delim, end);
+ if(argumentBeg != string::npos && str[argumentBeg] != '-')
+ {
+ beg = argumentBeg;
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+ argument = str.substr(beg, end - beg);
+ }
+
+ switch(option[1])
+ {
+ case 'h':
+ {
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ const_cast<string&>(_host) = argument;
+ break;
+ }
+
+ case 'p':
+ {
+ istringstream p(argument);
+ if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ break;
+ }
+
+ case 't':
+ {
+ istringstream t(argument);
+ if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ break;
+ }
+
+ case 'z':
+ {
+ if(!argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ const_cast<bool&>(_compress) = true;
+ break;
+ }
+
+ default:
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ }
}
}
@@ -181,11 +181,11 @@ IceInternal::TcpEndpointI::toString() const
s << "tcp -h " << _host << " -p " << _port;
if(_timeout != -1)
{
- s << " -t " << _timeout;
+ s << " -t " << _timeout;
}
if(_compress)
{
- s << " -z";
+ s << " -z";
}
return s.str();
}
@@ -207,11 +207,11 @@ IceInternal::TcpEndpointI::timeout(Int timeout) const
{
if(timeout == _timeout)
{
- return const_cast<TcpEndpointI*>(this);
+ return const_cast<TcpEndpointI*>(this);
}
else
{
- return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish);
+ return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish);
}
}
@@ -220,11 +220,11 @@ IceInternal::TcpEndpointI::connectionId(const string& connectionId) const
{
if(connectionId == _connectionId)
{
- return const_cast<TcpEndpointI*>(this);
+ return const_cast<TcpEndpointI*>(this);
}
else
{
- return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish);
+ return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish);
}
}
@@ -239,11 +239,11 @@ IceInternal::TcpEndpointI::compress(bool compress) const
{
if(compress == _compress)
{
- return const_cast<TcpEndpointI*>(this);
+ return const_cast<TcpEndpointI*>(this);
}
else
{
- return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish);
+ return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish);
}
}
@@ -297,18 +297,18 @@ IceInternal::TcpEndpointI::expand(bool server) const
{
if(_host.empty())
{
- const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost;
- if(_host.empty())
- {
- if(server)
- {
- const_cast<string&>(_host) = "0.0.0.0";
- }
- else
- {
- const_cast<string&>(_host) = "127.0.0.1";
- }
- }
+ const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost;
+ if(_host.empty())
+ {
+ if(server)
+ {
+ const_cast<string&>(_host) = "0.0.0.0";
+ }
+ else
+ {
+ const_cast<string&>(_host) = "127.0.0.1";
+ }
+ }
}
else if(_host == "*")
{
@@ -319,11 +319,11 @@ IceInternal::TcpEndpointI::expand(bool server) const
if(_host == "0.0.0.0")
{
vector<string> hosts = getLocalHosts();
- for(unsigned int i = 0; i < hosts.size(); ++i)
- {
- endps.push_back(new TcpEndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress,
- hosts.size() == 1 || hosts[i] != "127.0.0.1"));
- }
+ for(unsigned int i = 0; i < hosts.size(); ++i)
+ {
+ endps.push_back(new TcpEndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress,
+ hosts.size() == 1 || hosts[i] != "127.0.0.1"));
+ }
}
else
{
@@ -350,7 +350,7 @@ IceInternal::TcpEndpointI::equivalent(const AcceptorPtr& acceptor) const
const TcpAcceptor* tcpAcceptor = dynamic_cast<const TcpAcceptor*>(acceptor.get());
if(!tcpAcceptor)
{
- return false;
+ return false;
}
return tcpAcceptor->equivalent(_host, _port);
}
@@ -361,52 +361,52 @@ IceInternal::TcpEndpointI::operator==(const EndpointI& r) const
const TcpEndpointI* p = dynamic_cast<const TcpEndpointI*>(&r);
if(!p)
{
- return false;
+ return false;
}
if(this == p)
{
- return true;
+ return true;
}
if(_port != p->_port)
{
- return false;
+ return false;
}
if(_timeout != p->_timeout)
{
- return false;
+ return false;
}
if(_connectionId != p->_connectionId)
{
- return false;
+ return false;
}
if(_compress != p->_compress)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- struct sockaddr_in raddr;
- try
- {
- getAddress(_host, _port, laddr);
- getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ struct sockaddr_in raddr;
+ try
+ {
+ getAddress(_host, _port, laddr);
+ getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ return false;
+ }
- return compareAddress(laddr, raddr);
+ return compareAddress(laddr, raddr);
}
return true;
@@ -429,76 +429,76 @@ IceInternal::TcpEndpointI::operator<(const EndpointI& r) const
if(this == p)
{
- return false;
+ return false;
}
if(_port < p->_port)
{
- return true;
+ return true;
}
else if(p->_port < _port)
{
- return false;
+ return false;
}
if(_timeout < p->_timeout)
{
- return true;
+ return true;
}
else if(p->_timeout < _timeout)
{
- return false;
+ return false;
}
if(_connectionId < p->_connectionId)
{
- return true;
+ return true;
}
else if(p->_connectionId < _connectionId)
{
- return false;
+ return false;
}
if(!_compress && p->_compress)
{
- return true;
+ return true;
}
else if(p->_compress < _compress)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- try
- {
- getAddress(_host, _port, laddr);
- }
- catch(const DNSException&)
- {
- }
-
- struct sockaddr_in raddr;
- try
- {
- getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- }
-
- if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
- {
- return true;
- }
- else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ try
+ {
+ getAddress(_host, _port, laddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ struct sockaddr_in raddr;
+ try
+ {
+ getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
+ {
+ return true;
+ }
+ else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
+ {
+ return false;
+ }
}
return false;