Inheritance: TransportAddress
Example #1
0
    protected static TransportAddress NoCacheCreateInstance(string s) {
      string scheme = s.Substring(0, s.IndexOf(":"));
      string t = scheme.Substring(scheme.IndexOf('.') + 1);
      //Console.Error.WriteLine(t);
      
      TransportAddress result = null;
      TransportAddress.TAType ta_type = StringToType(t);
      
      switch(ta_type) {
        case TransportAddress.TAType.Tcp:
          result = new IPTransportAddress(s);
          break;
        case TransportAddress.TAType.Udp:
          result = new IPTransportAddress(s);
          break;
        case TransportAddress.TAType.Function:
          result = new IPTransportAddress(s);
          break;
        case TransportAddress.TAType.S:
          result = new SimulationTransportAddress(s);
          break;
        case TransportAddress.TAType.Tls:
          result = new IPTransportAddress(s);
          break;
        case TransportAddress.TAType.TlsTest:
          result = new IPTransportAddress(s);
          break;
        case TransportAddress.TAType.Tunnel:
          result = new TunnelTransportAddress(s);
          break;
      }

      return result;
    }
Example #2
0
        public static TransportAddress CreateInstance(TransportAddress.TAType t,
                                                      IPAddress host, int port)
        {
            Cache ta_cache = Interlocked.Exchange <Cache>(ref _ta_cache, null);

            if (ta_cache != null)
            {
                TransportAddress ta = null;
                try {
                    CacheKey key = new CacheKey(host, port, t);
                    ta = (TransportAddress)ta_cache[key];
                    if (ta == null)
                    {
                        ta            = new IPTransportAddress(t, host, port);
                        ta_cache[key] = ta;
                    }
                }
                finally {
                    Interlocked.Exchange <Cache>(ref _ta_cache, ta_cache);
                }
                return(ta);
            }
            else
            {
                return(new IPTransportAddress(t, host, port));
            }
        }
Example #3
0
        public static TransportAddress CreateInstance(TransportAddress.TAType t,
                                                      IPAddress host, int port)
        {
            var ta = new IPTransportAddress(t, host, port);

            return(CacheInstance(ta));
        }
Example #4
0
        public override bool Equals(object o)
        {
            if (o == this)
            {
                return(true);
            }
            IPTransportAddress other = o as IPTransportAddress;

            if (other == null)
            {
                return(false);
            }
            return(Uri.Equals(other.Uri));
        }
Example #5
0
        public void Test()
        {
            TransportAddress ta = new IPTransportAddress(
                "brunet.udp://127.0.0.1:9");
            TransportAddress ta0 = new IPTransportAddress(
                "brunet.udp:///127.0.0.1:9/Path");
            TransportAddress ta1 = new IPTransportAddress(
                "brunet.udp://127.0.0.1:9//Path");

            string path;

            PathELManager.SplitPath(ta, out path);
            Assert.AreEqual("/", path);
            PathELManager.SplitPath(ta0, out path);
            Assert.AreEqual("/Path", path);
            PathELManager.SplitPath(ta1, out path);
            Assert.AreEqual("/Path", path);
        }
Example #6
0
        protected static TransportAddress NoCacheCreateInstance(string s)
        {
            string scheme = s.Substring(0, s.IndexOf(":"));
            string t      = scheme.Substring(scheme.IndexOf('.') + 1);
            //Console.Error.WriteLine(t);

            TransportAddress result = null;

            TransportAddress.TAType ta_type = StringToType(t);

            switch (ta_type)
            {
            case TransportAddress.TAType.Tcp:
                result = new IPTransportAddress(s);
                break;

            case TransportAddress.TAType.Udp:
                result = new IPTransportAddress(s);
                break;

            case TransportAddress.TAType.Function:
                result = new IPTransportAddress(s);
                break;

            case TransportAddress.TAType.S:
                result = new SimulationTransportAddress(s);
                break;

            case TransportAddress.TAType.Tls:
                result = new IPTransportAddress(s);
                break;

            case TransportAddress.TAType.TlsTest:
                result = new IPTransportAddress(s);
                break;

            case TransportAddress.TAType.Tunnel:
                result = new TunnelTransportAddress(s);
                break;
            }

            return(result);
        }
Example #7
0
    public void Test() {
      TransportAddress ta = new IPTransportAddress(
          "brunet.udp://127.0.0.1:9");
      TransportAddress ta0 = new IPTransportAddress(
          "brunet.udp:///127.0.0.1:9/Path");
      TransportAddress ta1 = new IPTransportAddress(
          "brunet.udp://127.0.0.1:9//Path");

      string path;
      PathELManager.SplitPath(ta, out path);
      Assert.AreEqual("/", path);
      PathELManager.SplitPath(ta0, out path);
      Assert.AreEqual("/Path", path);
      PathELManager.SplitPath(ta1, out path);
      Assert.AreEqual("/Path", path);
    }
Example #8
0
 public static TransportAddress CreateInstance(TransportAddress.TAType t,
                         IPAddress host, int port) {
   Cache ta_cache = Interlocked.Exchange<Cache>(ref _ta_cache, null);
   if( ta_cache != null ) {
     TransportAddress ta = null;
     try {
       CacheKey key = new CacheKey(host, port, t);
       ta = (TransportAddress) ta_cache[key];
       if( ta == null ) {
         ta = new IPTransportAddress(t, host, port);
         ta_cache[key] = ta; 
        }
     }
     finally {
       Interlocked.Exchange<Cache>(ref _ta_cache, ta_cache);
     }
     return ta;
   }
   else {
     return new IPTransportAddress(t, host, port);
   }
 }
Example #9
0
 public static TransportAddress CreateInstance(TransportAddress.TAType t,
                         IPAddress host, int port) {
   var ta = new IPTransportAddress(t, host, port);
   return CacheInstance(ta);
 }