summaryrefslogtreecommitdiff
path: root/java/src/IceInternal/UdpEndpointI.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/IceInternal/UdpEndpointI.java')
-rw-r--r--java/src/IceInternal/UdpEndpointI.java470
1 files changed, 235 insertions, 235 deletions
diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java
index b78daccd0ec..6207a0499b8 100644
--- a/java/src/IceInternal/UdpEndpointI.java
+++ b/java/src/IceInternal/UdpEndpointI.java
@@ -19,14 +19,14 @@ final class UdpEndpointI extends EndpointI
_instance = instance;
_host = ho;
_port = po;
- _protocolMajor = Protocol.protocolMajor;
- _protocolMinor = Protocol.protocolMinor;
- _encodingMajor = Protocol.encodingMajor;
- _encodingMinor = Protocol.encodingMinor;
+ _protocolMajor = Protocol.protocolMajor;
+ _protocolMinor = Protocol.protocolMinor;
+ _encodingMajor = Protocol.encodingMajor;
+ _encodingMinor = Protocol.encodingMinor;
_connect = conn;
- _connectionId = conId;
- _compress = co;
- _publish = pub;
+ _connectionId = conId;
+ _compress = co;
+ _publish = pub;
calcHashValue();
}
@@ -36,13 +36,13 @@ final class UdpEndpointI extends EndpointI
_instance = instance;
_host = null;
_port = 0;
- _protocolMajor = Protocol.protocolMajor;
- _protocolMinor = Protocol.protocolMinor;
- _encodingMajor = Protocol.encodingMajor;
- _encodingMinor = Protocol.encodingMinor;
+ _protocolMajor = Protocol.protocolMajor;
+ _protocolMinor = Protocol.protocolMinor;
+ _encodingMajor = Protocol.encodingMajor;
+ _encodingMinor = Protocol.encodingMinor;
_connect = false;
- _compress = false;
- _publish = true;
+ _compress = false;
+ _publish = true;
String[] arr = str.split("[ \t\n\r]+");
@@ -58,7 +58,7 @@ final class UdpEndpointI extends EndpointI
String option = arr[i++];
if(option.length() != 2 || option.charAt(0) != '-')
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
String argument = null;
@@ -73,46 +73,46 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
- int pos = argument.indexOf('.');
+ int pos = argument.indexOf('.');
if(pos == -1)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
- String majStr = argument.substring(0, pos);
- String minStr = argument.substring(pos + 1, argument.length());
- int majVersion;
- int minVersion;
- try
- {
- majVersion = Integer.parseInt(majStr);
- minVersion = Integer.parseInt(minStr);
- }
+ String majStr = argument.substring(0, pos);
+ String minStr = argument.substring(pos + 1, argument.length());
+ int majVersion;
+ int minVersion;
+ try
+ {
+ majVersion = Integer.parseInt(majStr);
+ minVersion = Integer.parseInt(minStr);
+ }
catch(NumberFormatException ex)
- {
- throw new Ice.EndpointParseException("udp " + str);
- }
-
- if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
- {
- throw new Ice.EndpointParseException("udp " + str);
- }
-
- if(majVersion != Protocol.protocolMajor)
- {
- Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
- e.badMajor = majVersion < 0 ? majVersion + 255 : majVersion;
- e.badMinor = minVersion < 0 ? minVersion + 255 : minVersion;
- e.major = Protocol.protocolMajor;
- e.minor = Protocol.protocolMinor;
- throw e;
- }
-
- _protocolMajor = (byte)majVersion;
- _protocolMinor = (byte)minVersion;
+ {
+ throw new Ice.EndpointParseException("udp " + str);
+ }
+
+ if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
+ {
+ throw new Ice.EndpointParseException("udp " + str);
+ }
+
+ if(majVersion != Protocol.protocolMajor)
+ {
+ Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
+ e.badMajor = majVersion < 0 ? majVersion + 255 : majVersion;
+ e.badMinor = minVersion < 0 ? minVersion + 255 : minVersion;
+ e.major = Protocol.protocolMajor;
+ e.minor = Protocol.protocolMinor;
+ throw e;
+ }
+
+ _protocolMajor = (byte)majVersion;
+ _protocolMinor = (byte)minVersion;
break;
}
@@ -121,46 +121,46 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
- int pos = argument.indexOf('.');
+ int pos = argument.indexOf('.');
if(pos == -1)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
- String majStr = argument.substring(0, pos);
- String minStr = argument.substring(pos + 1, argument.length());
- int majVersion;
- int minVersion;
- try
- {
- majVersion = Integer.parseInt(majStr);
- minVersion = Integer.parseInt(minStr);
- }
+ String majStr = argument.substring(0, pos);
+ String minStr = argument.substring(pos + 1, argument.length());
+ int majVersion;
+ int minVersion;
+ try
+ {
+ majVersion = Integer.parseInt(majStr);
+ minVersion = Integer.parseInt(minStr);
+ }
catch(NumberFormatException ex)
- {
- throw new Ice.EndpointParseException("udp " + str);
- }
-
- if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
- {
- throw new Ice.EndpointParseException("udp " + str);
- }
-
- if(majVersion != Protocol.encodingMajor)
- {
- Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
- e.badMajor = majVersion < 0 ? majVersion + 255 : majVersion;
- e.badMinor = minVersion < 0 ? minVersion + 255 : minVersion;
- e.major = Protocol.encodingMajor;
- e.minor = Protocol.encodingMinor;
- throw e;
- }
-
- _encodingMajor = (byte)majVersion;
- _encodingMinor = (byte)minVersion;
+ {
+ throw new Ice.EndpointParseException("udp " + str);
+ }
+
+ if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
+ {
+ throw new Ice.EndpointParseException("udp " + str);
+ }
+
+ if(majVersion != Protocol.encodingMajor)
+ {
+ Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
+ e.badMajor = majVersion < 0 ? majVersion + 255 : majVersion;
+ e.badMinor = minVersion < 0 ? minVersion + 255 : minVersion;
+ e.major = Protocol.encodingMajor;
+ e.minor = Protocol.encodingMinor;
+ throw e;
+ }
+
+ _encodingMajor = (byte)majVersion;
+ _encodingMinor = (byte)minVersion;
break;
}
@@ -169,7 +169,7 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
_host = argument;
@@ -180,7 +180,7 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
try
@@ -189,13 +189,13 @@ final class UdpEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
- if(_port < 0 || _port > 65535)
- {
- throw new Ice.EndpointParseException("udp " + str);
- }
+ if(_port < 0 || _port > 65535)
+ {
+ throw new Ice.EndpointParseException("udp " + str);
+ }
break;
}
@@ -204,7 +204,7 @@ final class UdpEndpointI extends EndpointI
{
if(argument != null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
_connect = true;
@@ -215,7 +215,7 @@ final class UdpEndpointI extends EndpointI
{
if(argument != null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
_compress = true;
@@ -224,7 +224,7 @@ final class UdpEndpointI extends EndpointI
default:
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
}
}
@@ -237,34 +237,34 @@ final class UdpEndpointI extends EndpointI
s.startReadEncaps();
_host = s.readString();
_port = s.readInt();
- _protocolMajor = s.readByte();
- _protocolMinor = s.readByte();
- _encodingMajor = s.readByte();
- _encodingMinor = s.readByte();
- if(_protocolMajor != Protocol.protocolMajor)
- {
- Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
- e.badMajor = _protocolMajor < 0 ? _protocolMajor + 255 : _protocolMajor;
- e.badMinor = _protocolMinor < 0 ? _protocolMinor + 255 : _protocolMinor;
- e.major = Protocol.protocolMajor;
- e.minor = Protocol.protocolMinor;
- throw e;
- }
- if(_encodingMajor != Protocol.encodingMajor)
- {
- Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
- e.badMajor = _encodingMajor < 0 ? _encodingMajor + 255 : _encodingMajor;
- e.badMinor = _encodingMinor < 0 ? _encodingMinor + 255 : _encodingMinor;
- e.major = Protocol.encodingMajor;
- e.minor = Protocol.encodingMinor;
- throw e;
- }
+ _protocolMajor = s.readByte();
+ _protocolMinor = s.readByte();
+ _encodingMajor = s.readByte();
+ _encodingMinor = s.readByte();
+ if(_protocolMajor != Protocol.protocolMajor)
+ {
+ Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
+ e.badMajor = _protocolMajor < 0 ? _protocolMajor + 255 : _protocolMajor;
+ e.badMinor = _protocolMinor < 0 ? _protocolMinor + 255 : _protocolMinor;
+ e.major = Protocol.protocolMajor;
+ e.minor = Protocol.protocolMinor;
+ throw e;
+ }
+ if(_encodingMajor != Protocol.encodingMajor)
+ {
+ Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
+ e.badMajor = _encodingMajor < 0 ? _encodingMajor + 255 : _encodingMajor;
+ e.badMinor = _encodingMinor < 0 ? _encodingMinor + 255 : _encodingMinor;
+ e.major = Protocol.encodingMajor;
+ e.minor = Protocol.encodingMinor;
+ throw e;
+ }
// Not transmitted.
//_connect = s.readBool();
_connect = false;
- _compress = s.readBool();
+ _compress = s.readBool();
s.endReadEncaps();
- _publish = true;
+ _publish = true;
calcHashValue();
}
@@ -278,13 +278,13 @@ final class UdpEndpointI extends EndpointI
s.startWriteEncaps();
s.writeString(_host);
s.writeInt(_port);
- s.writeByte(_protocolMajor);
- s.writeByte(_protocolMinor);
- s.writeByte(_encodingMajor);
- s.writeByte(_encodingMinor);
+ s.writeByte(_protocolMajor);
+ s.writeByte(_protocolMinor);
+ s.writeByte(_encodingMajor);
+ s.writeByte(_encodingMinor);
// Not transmitted.
//s.writeBool(_connect);
- s.writeBool(_compress);
+ s.writeBool(_compress);
s.endWriteEncaps();
}
@@ -294,38 +294,38 @@ final class UdpEndpointI extends EndpointI
public String
_toString()
{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
+ //
+ // WARNING: Certain features, such as proxy validation in Glacier2,
+ // depend on the format of proxy strings. Changes to toString() and
+ // methods called to generate parts of the reference string could break
+ // these features. Please review for all features that depend on the
+ // format of proxyToString() before changing this and related code.
+ //
String s = "udp";
- if((int)_protocolMajor != 1 || (int)_protocolMinor != 0)
- {
- s += " -v " + (_protocolMajor < 0 ? (int)_protocolMajor + 255 : _protocolMajor)
- + "." + (_protocolMinor < 0 ? (int)_protocolMinor + 255 : _protocolMinor);
- }
+ if((int)_protocolMajor != 1 || (int)_protocolMinor != 0)
+ {
+ s += " -v " + (_protocolMajor < 0 ? (int)_protocolMajor + 255 : _protocolMajor)
+ + "." + (_protocolMinor < 0 ? (int)_protocolMinor + 255 : _protocolMinor);
+ }
- if((int)_encodingMajor != 1 || (int)_encodingMinor != 0)
- {
- s += " -e " + (_encodingMajor < 0 ? (int)_encodingMajor + 255 : _encodingMajor)
- + "." + (_encodingMinor < 0 ? (int)_encodingMinor + 255 : _encodingMinor);
- }
+ if((int)_encodingMajor != 1 || (int)_encodingMinor != 0)
+ {
+ s += " -e " + (_encodingMajor < 0 ? (int)_encodingMajor + 255 : _encodingMajor)
+ + "." + (_encodingMinor < 0 ? (int)_encodingMinor + 255 : _encodingMinor);
+ }
- s += " -h " + _host + " -p " + _port;
+ s += " -h " + _host + " -p " + _port;
if(_connect)
{
s += " -c";
}
- if(_compress)
- {
- s += " -z";
- }
+ if(_compress)
+ {
+ s += " -z";
+ }
return s;
}
@@ -453,7 +453,7 @@ final class UdpEndpointI extends EndpointI
{
UdpTransceiver p = new UdpTransceiver(_instance, _host, _port, _connect);
endpoint.value = new UdpEndpointI(_instance, _host, p.effectivePort(), _connect, _connectionId, _compress,
- _publish);
+ _publish);
return p;
}
@@ -494,20 +494,20 @@ final class UdpEndpointI extends EndpointI
_host = _instance.defaultsAndOverrides().defaultHost;
if(_host == null)
{
- if(server)
- {
- _host = "0.0.0.0";
- }
- else
- {
- _host = "127.0.0.1";
- }
+ if(server)
+ {
+ _host = "0.0.0.0";
+ }
+ else
+ {
+ _host = "127.0.0.1";
+ }
}
}
- else if(_host.equals("*"))
- {
- _host = "0.0.0.0";
- }
+ else if(_host.equals("*"))
+ {
+ _host = "0.0.0.0";
+ }
java.util.ArrayList endps = new java.util.ArrayList();
if(_host.equals("0.0.0.0"))
@@ -518,12 +518,12 @@ final class UdpEndpointI extends EndpointI
{
String host = (String)iter.next();
endps.add(new UdpEndpointI(_instance, host, _port, _connect, _connectionId, _compress,
- hosts.size() == 1 || !host.equals("127.0.0.1")));
+ hosts.size() == 1 || !host.equals("127.0.0.1")));
}
}
else
{
- calcHashValue();
+ calcHashValue();
endps.add(this);
}
return endps;
@@ -616,10 +616,10 @@ final class UdpEndpointI extends EndpointI
return 1;
}
- if(!_connectionId.equals(p._connectionId))
- {
- return _connectionId.compareTo(p._connectionId);
- }
+ if(!_connectionId.equals(p._connectionId))
+ {
+ return _connectionId.compareTo(p._connectionId);
+ }
if(!_compress && p._compress)
{
@@ -630,41 +630,41 @@ final class UdpEndpointI extends EndpointI
return 1;
}
- if(_protocolMajor < p._protocolMajor)
- {
- return -1;
- }
- else if(p._protocolMajor < _protocolMajor)
- {
- return 1;
- }
-
- if(_protocolMinor < p._protocolMinor)
- {
- return -1;
- }
- else if(p._protocolMinor < _protocolMinor)
- {
- return 1;
- }
-
- if(_encodingMajor < p._encodingMajor)
- {
- return -1;
- }
- else if(p._encodingMajor < _encodingMajor)
- {
- return 1;
- }
-
- if(_encodingMinor < p._encodingMinor)
- {
- return -1;
- }
- else if(p._encodingMinor < _encodingMinor)
- {
- return 1;
- }
+ if(_protocolMajor < p._protocolMajor)
+ {
+ return -1;
+ }
+ else if(p._protocolMajor < _protocolMajor)
+ {
+ return 1;
+ }
+
+ if(_protocolMinor < p._protocolMinor)
+ {
+ return -1;
+ }
+ else if(p._protocolMinor < _protocolMinor)
+ {
+ return 1;
+ }
+
+ if(_encodingMajor < p._encodingMajor)
+ {
+ return -1;
+ }
+ else if(p._encodingMajor < _encodingMajor)
+ {
+ return 1;
+ }
+
+ if(_encodingMinor < p._encodingMinor)
+ {
+ return -1;
+ }
+ else if(p._encodingMinor < _encodingMinor)
+ {
+ return 1;
+ }
if(!_host.equals(p._host))
{
@@ -672,48 +672,48 @@ final class UdpEndpointI extends EndpointI
// We do the most time-consuming part of the comparison last.
//
java.net.InetSocketAddress laddr = null;
- try
- {
- laddr = Network.getAddress(_host, _port);
- }
- catch(Ice.DNSException ex)
- {
- }
+ try
+ {
+ laddr = Network.getAddress(_host, _port);
+ }
+ catch(Ice.DNSException ex)
+ {
+ }
java.net.InetSocketAddress raddr = null;
- try
- {
- raddr = Network.getAddress(p._host, p._port);
- }
- catch(Ice.DNSException ex)
- {
- }
-
- if(laddr == null && raddr != null)
- {
- return -1;
- }
- else if(raddr == null && laddr != null)
- {
- return 1;
- }
- else if(laddr != null && raddr != null)
- {
- byte[] larr = laddr.getAddress().getAddress();
- byte[] rarr = raddr.getAddress().getAddress();
- assert(larr.length == rarr.length);
- for(int i = 0; i < larr.length; i++)
- {
- if(larr[i] < rarr[i])
- {
- return -1;
- }
- else if(rarr[i] < larr[i])
- {
- return 1;
- }
- }
- }
+ try
+ {
+ raddr = Network.getAddress(p._host, p._port);
+ }
+ catch(Ice.DNSException ex)
+ {
+ }
+
+ if(laddr == null && raddr != null)
+ {
+ return -1;
+ }
+ else if(raddr == null && laddr != null)
+ {
+ return 1;
+ }
+ else if(laddr != null && raddr != null)
+ {
+ byte[] larr = laddr.getAddress().getAddress();
+ byte[] rarr = raddr.getAddress().getAddress();
+ assert(larr.length == rarr.length);
+ for(int i = 0; i < larr.length; i++)
+ {
+ if(larr[i] < rarr[i])
+ {
+ return -1;
+ }
+ else if(rarr[i] < larr[i])
+ {
+ return 1;
+ }
+ }
+ }
}
return 0;