From 44f954da520f20b5b14a040eee2ae506e6935f5f Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:51:11 +0000 Subject: Utilisateur : Fcolin Date : 30/11/05 Heure : 10:27 Archivé dans $/CSharp/Ivy Commentaire: (vss 2) --- CSharp/Ivy/Ivy/IvyUDPStreamV4.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'CSharp') 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() { -- cgit v1.1