summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CSharp/Ivy/Ivy/IvyUDPStreamV4.cs17
1 files changed, 13 insertions, 4 deletions
diff --git a/CSharp/Ivy/Ivy/IvyUDPStreamV4.cs b/CSharp/Ivy/Ivy/IvyUDPStreamV4.cs
index d5319c8..8eebecd 100644
--- a/CSharp/Ivy/Ivy/IvyUDPStreamV4.cs
+++ b/CSharp/Ivy/Ivy/IvyUDPStreamV4.cs
@@ -16,6 +16,8 @@ namespace IvyBus
MemoryStream out_stream;
MemoryStream in_stream;
+ /// the protocol version number
+ internal const int PROCOCOLVERSION = 4;
public IvyUDPStream(Socket _socket)
{
socket = _socket;
@@ -25,6 +27,13 @@ namespace IvyBus
out_stream = new MemoryStream();
output = new BinaryWriter(out_stream, Encoding.ASCII);
}
+ /*
+ * message Syntax:
+ * this is a binary formated message use of network representation
+ *
+ * message Format:
+ protocol_version, TCP server port , lenAppId, appId, lenAppNameId, appName
+ */
internal void receiveMsg(out IPEndPoint remote, out int version, out int port, out string appId, out string appName)
{
@@ -39,14 +48,14 @@ namespace IvyBus
port = (ushort)IPAddress.NetworkToHostOrder((short)input.ReadUInt16());
int lenAppId = (ushort)IPAddress.NetworkToHostOrder((short)input.ReadUInt16());
appId = new String(input.ReadChars(lenAppId));
- int lenAppNameId = (ushort)IPAddress.NetworkToHostOrder((short)input.ReadUInt16());
- appName = new String(input.ReadChars(lenAppNameId));
+ int lenAppName = (ushort)IPAddress.NetworkToHostOrder((short)input.ReadUInt16());
+ appName = new String(input.ReadChars(lenAppName));
}
internal void sendMsg(IPEndPoint EPhost, int port, string appId, string appName)
{
- output.Write((ushort)IPAddress.HostToNetworkOrder((short)(Ivy.PROCOCOLVERSION)));
+ output.Write((ushort)IPAddress.HostToNetworkOrder((short)(PROCOCOLVERSION)));
output.Write((ushort)IPAddress.HostToNetworkOrder((short)port));
output.Write((ushort)IPAddress.HostToNetworkOrder((short)appId.Length));
output.Write(appId.ToCharArray());
@@ -55,7 +64,7 @@ namespace IvyBus
output.Flush();
byte[] hellob = out_stream.GetBuffer();
- socket.SendTo(hellob, (int)out_stream.Length, 0, EPhost); // notifies our arrival on each domain: protocol version + port
+ socket.SendTo(hellob, (int)out_stream.Length, 0, EPhost);
}
internal void Close()
{