summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2003-03-03 06:13:53 +0000
committerMichi Henning <michi@zeroc.com>2003-03-03 06:13:53 +0000
commit0609f08160e409bbba2d716cc05d01004d7de457 (patch)
tree7aa6e97d36845e448c9b6a877ee0bdac33ef65f7 /java
parentminor edit (diff)
downloadice-0609f08160e409bbba2d716cc05d01004d7de457.tar.bz2
ice-0609f08160e409bbba2d716cc05d01004d7de457.tar.xz
ice-0609f08160e409bbba2d716cc05d01004d7de457.zip
Added magic number and versioning to Ice protocol. Encapsulations are still
written with version number *outside* the encapsulation. Will probably change that to inside soon.
Diffstat (limited to 'java')
-rw-r--r--java/demo/Ice/hello/config2
-rw-r--r--java/src/IceInternal/BasicStream.java43
-rw-r--r--java/src/IceInternal/Connection.java148
-rw-r--r--java/src/IceInternal/Protocol.java15
-rw-r--r--java/src/IceInternal/ThreadPool.java46
-rw-r--r--java/src/IceInternal/TraceUtil.java18
-rw-r--r--java/src/IceInternal/UdpEndpoint.java189
7 files changed, 401 insertions, 60 deletions
diff --git a/java/demo/Ice/hello/config b/java/demo/Ice/hello/config
index e1b1f26f4c3..eed55243be9 100644
--- a/java/demo/Ice/hello/config
+++ b/java/demo/Ice/hello/config
@@ -2,7 +2,7 @@
# The client reads this property to create the reference to the
# "hello" object in the server.
#
-Hello.Proxy=hello:tcp -p 10000:udp -p 10000
+Hello.Proxy=hello:tcp -p 10000:udp -v 1.0 -e 1.0 -p 10000
#
# The server creates one single object adapter with the name
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java
index 50b96d75c22..12e6f64ceb1 100644
--- a/java/src/IceInternal/BasicStream.java
+++ b/java/src/IceInternal/BasicStream.java
@@ -171,7 +171,8 @@ public class BasicStream
public void
startWriteEncaps()
{
- writeByte((byte)0); // Encoding
+ writeByte(Protocol.encodingMajor);
+ writeByte(Protocol.encodingMinor);
writeInt(0); // Placeholder for the encapsulation length
WriteEncaps curr = _writeEncapsCache;
if(curr != null)
@@ -182,7 +183,6 @@ public class BasicStream
{
curr = new WriteEncaps();
}
- curr.encoding = 0;
curr.start = _buf.position();
curr.next = _writeEncapsStack;
_writeEncapsStack = curr;
@@ -208,11 +208,17 @@ public class BasicStream
public void
startReadEncaps()
{
- byte encoding = readByte();
- if(encoding != 0)
- {
- throw new Ice.UnsupportedEncodingException();
- }
+ byte eMajor = readByte();
+ byte eMinor = readByte();
+ if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor)
+ {
+ Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
+ e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor;
+ e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor;
+ e.major = Protocol.encodingMajor;
+ e.minor = Protocol.encodingMinor;
+ throw e;
+ }
//
// I don't use readSize() and writeSize() for encapsulations,
// because when creating an encapsulation, I must know in
@@ -235,7 +241,8 @@ public class BasicStream
{
curr = new ReadEncaps();
}
- curr.encoding = encoding;
+ curr.encodingMajor = eMajor;
+ curr.encodingMinor = eMinor;
curr.start = _buf.position();
curr.next = _readEncapsStack;
_readEncapsStack = curr;
@@ -314,11 +321,17 @@ public class BasicStream
public void
skipEncaps()
{
- byte encoding = readByte();
- if(encoding != 0)
- {
- throw new Ice.UnsupportedEncodingException();
- }
+ byte version = readByte(); // Ignore major
+ version = readByte(); // Ignore minor
+
+ //
+ // We don't check the encoding here because encapsulations always
+ // have the encoding followed by the size of the encapsulation
+ // (regardless of the version of the encoding). We care about the
+ // version information only if we want to decode what's in the
+ // encapsulation.
+ //
+
int sz = readInt();
if(sz < 0)
{
@@ -1323,7 +1336,8 @@ public class BasicStream
private static final class ReadEncaps
{
int start;
- byte encoding;
+ byte encodingMajor;
+ byte encodingMinor;
java.util.ArrayList objectsRead;
ReadEncaps next;
}
@@ -1331,7 +1345,6 @@ public class BasicStream
private static final class WriteEncaps
{
int start;
- byte encoding;
java.util.IdentityHashMap objectsWritten;
WriteEncaps next;
}
diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java
index 35ae3e5ce69..e761caaf906 100644
--- a/java/src/IceInternal/Connection.java
+++ b/java/src/IceInternal/Connection.java
@@ -158,8 +158,14 @@ public final class Connection extends EventHandler
// respect to connection validation.
//
BasicStream os = new BasicStream(_instance);
- os.writeByte(Protocol.protocolVersion);
- os.writeByte(Protocol.encodingVersion);
+ os.writeByte((byte)0x49); // 'I'
+ os.writeByte((byte)0x63); // 'c'
+ os.writeByte((byte)0x65); // 'e'
+ os.writeByte((byte)0x50); // 'P'
+ os.writeByte(Protocol.protocolMajor);
+ os.writeByte(Protocol.protocolMinor);
+ os.writeByte(Protocol.encodingMajor);
+ os.writeByte(Protocol.encodingMinor);
os.writeByte(Protocol.validateConnectionMsg);
os.writeInt(Protocol.headerSize); // Message size.
TraceUtil.traceHeader("sending validate connection", os, _logger, _traceLevels);
@@ -178,16 +184,60 @@ public final class Connection extends EventHandler
int pos = is.pos();
assert(pos >= Protocol.headerSize);
is.pos(0);
- byte protVer = is.readByte();
- if(protVer != Protocol.protocolVersion)
+ byte[] magic = new byte[4];
+ magic[0] = is.readByte();
+ magic[1] = is.readByte();
+ magic[2] = is.readByte();
+ magic[3] = is.readByte();
+ if(magic[0] != 0x49 || magic[1] != 0x63 || magic[2] != 0x65 || magic[3] != 0x50)
{
- throw new Ice.UnsupportedProtocolException();
+ Ice.BadMagicException ex = new Ice.BadMagicException();
+ ex.badMagic = magic;
+ throw ex;
}
- byte encVer = is.readByte();
- if(encVer != Protocol.encodingVersion)
+ byte pMajor = is.readByte();
+ byte pMinor = is.readByte();
+
+ //
+ // We only check the major version number here. The minor version
+ // number is irrelevant -- no matter what minor version number is offered
+ // by the server, we can be certain that the server supports at least minor version 0.
+ // As the client, we are obliged to never produce a message with a minor
+ // version number that is larger than what the server can understand, but we don't
+ // care if the server understands more than we do.
+ //
+ // Note: Once we add minor versions, we need to modify the client side to never produce
+ // a message with a minor number that is greater than what the server can handle. Similarly,
+ // the server side will have to be modified so it never replies with a minor version that is
+ // greater than what the client can handle.
+ //
+ if(pMajor != Protocol.protocolMajor)
+ {
+ Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
+ e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor;
+ e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor;
+ e.major = Protocol.protocolMajor;
+ e.minor = Protocol.protocolMinor;
+ throw e;
+ }
+
+ byte eMajor = is.readByte();
+ byte eMinor = is.readByte();
+
+ //
+ // The same applies here as above -- only the major version number
+ // of the encoding is relevant.
+ //
+ if(eMajor != Protocol.encodingMajor)
{
- throw new Ice.UnsupportedEncodingException();
+ Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
+ e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor;
+ e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor;
+ e.major = Protocol.encodingMajor;
+ e.minor = Protocol.encodingMinor;
+ throw e;
}
+
byte messageType = is.readByte();
if(messageType != Protocol.validateConnectionMsg)
{
@@ -263,8 +313,11 @@ public final class Connection extends EventHandler
private final static byte[] _requestHdr =
{
- Protocol.protocolVersion,
- Protocol.encodingVersion,
+ (byte)0x49, (byte)0x63, (byte)0x65, (byte)0x50, // 'I', 'c', 'e', 'P'
+ Protocol.protocolMajor,
+ Protocol.protocolMinor,
+ Protocol.encodingMajor,
+ Protocol.encodingMinor,
Protocol.requestMsg,
(byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder).
(byte)0, (byte)0, (byte)0, (byte)0 // Request ID (placeholder).
@@ -290,7 +343,7 @@ public final class Connection extends EventHandler
try
{
BasicStream os = out.os();
- os.pos(3);
+ os.pos(9);
//
// Fill in the message size and request ID.
@@ -349,7 +402,7 @@ public final class Connection extends EventHandler
try
{
BasicStream os = out.__os();
- os.pos(3);
+ os.pos(9);
//
// Fill in the message size and request ID.
@@ -389,8 +442,11 @@ public final class Connection extends EventHandler
private final static byte[] _requestBatchHdr =
{
- Protocol.protocolVersion,
- Protocol.encodingVersion,
+ (byte)0x49, (byte)0x63, (byte)0x65, (byte)0x50, // 'I', 'c', 'e', 'P'
+ Protocol.protocolMajor,
+ Protocol.protocolMinor,
+ Protocol.encodingMajor,
+ Protocol.encodingMinor,
Protocol.requestBatchMsg,
(byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder).
(byte)0, (byte)0, (byte)0, (byte)0 // Number of requests in batch (placeholder).
@@ -498,7 +554,7 @@ public final class Connection extends EventHandler
try
{
- _batchStream.pos(3);
+ _batchStream.pos(9);
//
// Fill in the message size.
@@ -554,7 +610,7 @@ public final class Connection extends EventHandler
//
// Fill in the message size.
//
- os.pos(3);
+ os.pos(9);
final int sz = os.size();
os.writeInt(sz);
@@ -686,8 +742,11 @@ public final class Connection extends EventHandler
private final static byte[] _replyHdr =
{
- Protocol.protocolVersion,
- Protocol.encodingVersion,
+ (byte)0x49, (byte)0x63, (byte)0x65, (byte)0x50, // 'I', 'c', 'e', 'P'
+ Protocol.protocolMajor,
+ Protocol.protocolMinor,
+ Protocol.encodingMajor,
+ Protocol.encodingMinor,
Protocol.replyMsg,
(byte)0, (byte)0, (byte)0, (byte)0 // Message size (placeholder).
};
@@ -718,7 +777,44 @@ public final class Connection extends EventHandler
try
{
assert(stream.pos() == stream.size());
- stream.pos(2);
+ stream.pos(0);
+
+ byte[] magic = new byte[4];
+ magic[0] = stream.readByte();
+ magic[1] = stream.readByte();
+ magic[2] = stream.readByte();
+ magic[3] = stream.readByte();
+ if(magic[0] != 0x49 || magic[1] != 0x63 || magic[2] != 0x65 || magic[3] != 0x50)
+ {
+ Ice.BadMagicException ex = new Ice.BadMagicException();
+ ex.badMagic = magic;
+ throw ex;
+ }
+
+ byte pMajor = stream.readByte();
+ byte pMinor = stream.readByte();
+ if(pMajor != Protocol.protocolMajor || pMinor > Protocol.protocolMinor)
+ {
+ Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
+ e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor;
+ e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor;
+ e.major = Protocol.protocolMajor;
+ e.minor = Protocol.protocolMinor;
+ throw e;
+ }
+
+ byte eMajor = stream.readByte();
+ byte eMinor = stream.readByte();
+ if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor)
+ {
+ Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
+ e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor;
+ e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor;
+ e.major = Protocol.encodingMajor;
+ e.minor = Protocol.encodingMinor;
+ throw e;
+ }
+
byte messageType = stream.readByte();
stream.pos(Protocol.headerSize);
@@ -956,8 +1052,8 @@ public final class Connection extends EventHandler
_transceiver = transceiver;
_endpoint = endpoint;
_adapter = adapter;
- _logger = instance.logger(); // Chached for better performance.
- _traceLevels = instance.traceLevels(); // Chached for better performance.
+ _logger = instance.logger(); // Cached for better performance.
+ _traceLevels = instance.traceLevels(); // Cached for better performance.
_registeredWithPool = false;
_warn = false;
_acmTimeout = 0;
@@ -1172,8 +1268,14 @@ public final class Connection extends EventHandler
// message.
//
BasicStream os = new BasicStream(_instance);
- os.writeByte(Protocol.protocolVersion);
- os.writeByte(Protocol.encodingVersion);
+ os.writeByte((byte)0x49); // 'I'
+ os.writeByte((byte)0x63); // 'c'
+ os.writeByte((byte)0x65); // 'e'
+ os.writeByte((byte)0x50); // 'P'
+ os.writeByte(Protocol.protocolMajor);
+ os.writeByte(Protocol.protocolMinor);
+ os.writeByte(Protocol.encodingMajor);
+ os.writeByte(Protocol.encodingMinor);
os.writeByte(Protocol.closeConnectionMsg);
os.writeInt(Protocol.headerSize); // Message size.
_transceiver.write(os, _endpoint.timeout());
diff --git a/java/src/IceInternal/Protocol.java b/java/src/IceInternal/Protocol.java
index c38f47fc06c..526c850da72 100644
--- a/java/src/IceInternal/Protocol.java
+++ b/java/src/IceInternal/Protocol.java
@@ -19,18 +19,23 @@ final class Protocol
//
// Size of the Ice protocol header
//
- // Protocol version (Byte)
- // Encoding version (Byte)
+ // Magic number (4 bytes): 'I', 'c', 'e', 'P' in ASCII encoding
+ // Protocol version major (Byte)
+ // Protocol version minor (Byte)
+ // Encoding version major (Byte)
+ // Encoding version minor (Byte)
// Message type (Byte)
// Message size (Int)
//
- final static int headerSize = 7;
+ final static int headerSize = 13;
//
// The current Ice protocol and encoding version
//
- final static byte protocolVersion = 0;
- final static byte encodingVersion = 0;
+ final static byte protocolMajor = 1;
+ final static byte protocolMinor = 0;
+ final static byte encodingMajor = 1;
+ final static byte encodingMinor = 0;
//
// The Ice protocol message types
diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java
index 203eec0ffe2..6078c616a13 100644
--- a/java/src/IceInternal/ThreadPool.java
+++ b/java/src/IceInternal/ThreadPool.java
@@ -658,16 +658,42 @@ public final class ThreadPool
int pos = stream.pos();
assert(pos >= Protocol.headerSize);
stream.pos(0);
- byte protVer = stream.readByte();
- if(protVer != Protocol.protocolVersion)
- {
- throw new Ice.UnsupportedProtocolException();
- }
- byte encVer = stream.readByte();
- if(encVer != Protocol.encodingVersion)
- {
- throw new Ice.UnsupportedEncodingException();
- }
+ byte[] magic = new byte[4];
+ magic[0] = stream.readByte();
+ magic[1] = stream.readByte();
+ magic[2] = stream.readByte();
+ magic[3] = stream.readByte();
+ if(magic[0] != 0x49 || magic[1] != 0x63 || magic[2] != 0x65 || magic[3] != 0x50)
+ {
+ Ice.BadMagicException ex = new Ice.BadMagicException();
+ ex.badMagic = magic;
+ throw ex;
+ }
+
+ byte pMajor = stream.readByte();
+ byte pMinor = stream.readByte();
+ if(pMajor != Protocol.protocolMajor || pMinor > Protocol.protocolMinor)
+ {
+ Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
+ e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor;
+ e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor;
+ e.major = Protocol.protocolMajor;
+ e.minor = Protocol.protocolMinor;
+ throw e;
+ }
+
+ byte eMajor = stream.readByte();
+ byte eMinor = stream.readByte();
+ if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor)
+ {
+ Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
+ e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor;
+ e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor;
+ e.major = Protocol.encodingMajor;
+ e.minor = Protocol.encodingMinor;
+ throw e;
+ }
+
byte messageType = stream.readByte();
int size = stream.readInt();
if(size < Protocol.headerSize)
diff --git a/java/src/IceInternal/TraceUtil.java b/java/src/IceInternal/TraceUtil.java
index 8ce03d4b7ec..52771b1fc96 100644
--- a/java/src/IceInternal/TraceUtil.java
+++ b/java/src/IceInternal/TraceUtil.java
@@ -333,11 +333,19 @@ final class TraceUtil
{
try
{
- byte protVer = stream.readByte();
-// out.write("\nprotocol version = " + (int)protVer);
-
- byte encVer = stream.readByte();
-// out.write("\nencoding version = " + (int)encVer);
+ byte[] magic = new byte[4];
+ magic[0] = stream.readByte();
+ magic[1] = stream.readByte();
+ magic[2] = stream.readByte();
+ magic[3] = stream.readByte();
+
+ byte pMajor = stream.readByte();
+ byte pMinor = stream.readByte();
+// out.write("\nprotocol version = " + (int)pMajor + "." + (int)pMinor);
+
+ byte eMajor = stream.readByte();
+ byte eMinor = stream.readByte();
+// out.write("\nencoding version = " + (int)eMajor + "." + (int)eMinor);
byte type = stream.readByte();
out.write("\nmessage type = " + (int)type + ' ');
diff --git a/java/src/IceInternal/UdpEndpoint.java b/java/src/IceInternal/UdpEndpoint.java
index b9c5c953c41..ce9bc3d71e2 100644
--- a/java/src/IceInternal/UdpEndpoint.java
+++ b/java/src/IceInternal/UdpEndpoint.java
@@ -24,6 +24,10 @@ final class UdpEndpoint implements Endpoint
_instance = instance;
_host = ho;
_port = po;
+ _protocolMajor = Protocol.protocolMajor;
+ _protocolMinor = Protocol.protocolMinor;
+ _encodingMajor = Protocol.encodingMajor;
+ _encodingMinor = Protocol.encodingMinor;
_connect = false;
_compress = co;
calcHashValue();
@@ -65,6 +69,118 @@ final class UdpEndpoint implements Endpoint
switch(option.charAt(1))
{
+ case 'v':
+ {
+ if(argument == null)
+ {
+ Ice.EndpointParseException e = new Ice.EndpointParseException();
+ e.str = "udp " + str;
+ throw e;
+ }
+
+ int pos = argument.indexOf('.');
+ if(pos == -1)
+ {
+ Ice.EndpointParseException e = new Ice.EndpointParseException();
+ e.str = "udp " + str;
+ throw e;
+ }
+
+ 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)
+ {
+ Ice.EndpointParseException e = new Ice.EndpointParseException();
+ e.str = "udp " + str;
+ throw e;
+ }
+
+ if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
+ {
+ Ice.EndpointParseException e = new Ice.EndpointParseException();
+ e.str = "udp " + str;
+ throw e;
+ }
+
+ 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;
+ }
+
+ case 'e':
+ {
+ if(argument == null)
+ {
+ Ice.EndpointParseException e = new Ice.EndpointParseException();
+ e.str = "udp " + str;
+ throw e;
+ }
+
+ int pos = argument.indexOf('.');
+ if(pos == -1)
+ {
+ Ice.EndpointParseException e = new Ice.EndpointParseException();
+ e.str = "udp " + str;
+ throw e;
+ }
+
+ 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)
+ {
+ Ice.EndpointParseException e = new Ice.EndpointParseException();
+ e.str = "udp " + str;
+ throw e;
+ }
+
+ if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
+ {
+ Ice.EndpointParseException e = new Ice.EndpointParseException();
+ e.str = "udp " + str;
+ throw e;
+ }
+
+ 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;
+ }
+
case 'h':
{
if(argument == null)
@@ -151,6 +267,28 @@ final class UdpEndpoint implements Endpoint
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;
+ }
// Not transmitted.
//_connect = s.readBool();
_connect = false;
@@ -169,6 +307,10 @@ final class UdpEndpoint implements Endpoint
s.startWriteEncaps();
s.writeString(_host);
s.writeInt(_port);
+ s.writeByte(_protocolMajor);
+ s.writeByte(_protocolMinor);
+ s.writeByte(_encodingMajor);
+ s.writeByte(_encodingMinor);
// Not transmitted.
//s.writeBool(_connect);
s.writeBool(_compress);
@@ -181,7 +323,12 @@ final class UdpEndpoint implements Endpoint
public String
toString()
{
- String s = "udp -h " + _host + " -p " + _port;
+ String s = "udp";
+ s += " -v " + (_protocolMajor < 0 ? (int)_protocolMajor + 255 : _protocolMajor)
+ + "." + (_protocolMinor < 0 ? (int)_protocolMinor + 255 : _protocolMinor);
+ s += " -e " + (_encodingMajor < 0 ? (int)_encodingMajor + 255 : _encodingMajor)
+ + "." + (_encodingMinor < 0 ? (int)_encodingMinor + 255 : _encodingMinor);
+ s += " -h " + _host + " -p " + _port;
if(_connect)
{
s += " -c";
@@ -413,6 +560,42 @@ final class UdpEndpoint implements Endpoint
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))
{
//
@@ -453,6 +636,10 @@ final class UdpEndpoint implements Endpoint
private Instance _instance;
private String _host;
private int _port;
+ private byte _protocolMajor;
+ private byte _protocolMinor;
+ private byte _encodingMajor;
+ private byte _encodingMinor;
private boolean _connect;
private boolean _compress;
private int _hashCode;