The Labs \ Source Viewer \ SSCLI \ System.Runtime.Remoting.Channels.Tcp \ TcpChannelHelper

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. //==========================================================================
  16. // File: TcpChannelHelper.cs
  17. //
  18. // Summary: Implements helper methods for tcp client and server channels.
  19. //
  20. //==========================================================================
  21. using System;
  22. using System.Text;
  23. using System.Runtime.Remoting.Channels;
  24. namespace System.Runtime.Remoting.Channels.Tcp
  25. {
  26.    
  27.     static internal class TcpChannelHelper
  28.     {
  29.         private const string _tcp = "tcp://";
  30.        
  31.         // Used by tcp channels to implement IChannel::Parse.
  32.         // It returns the channel uri and places object uri into out parameter.
  33.         static internal string ParseURL(string url, out string objectURI)
  34.         {
  35.             // Set the out parameters
  36.             objectURI = null;
  37.            
  38.             int separator;
  39.            
  40.             // Find the starting point of tcp://
  41.             // NOTE: We are using this version of String.Compare to ensure
  42.             // that string operations are case-insensitive!!
  43.             if (StringHelper.StartsWithAsciiIgnoreCasePrefixLower(url, _tcp)) {
  44.                 separator = _tcp.Length;
  45.             }
  46.             else {
  47.                 return null;
  48.             }
  49.            
  50.             // find next slash (after end of scheme)
  51.             separator = url.IndexOf('/', separator);
  52.             if (-1 == separator) {
  53.                 return url;
  54.                 // means that the url is just "tcp://foo:90" or something like that
  55.             }
  56.            
  57.             // Extract the channel URI which is the prefix
  58.             string channelURI = url.Substring(0, separator);
  59.            
  60.             // Extract the object URI which is the suffix
  61.             objectURI = url.Substring(separator);
  62.             // leave the slash
  63.             return channelURI;
  64.         }
  65.         // ParseURL
  66.        
  67.     }
  68.     // class TcpChannelHelper
  69.    
  70. }
  71. // namespace System.Runtime.Remoting.Channels.Tcp

Developer Fusion