Exemple #1
0
        public TcpServerPort(PortConfig portConfig, IPPortEndpointConfig serverPortEndpointConfig)
            : base(portConfig, new IPPortEndpointConfig("", new IPEndPoint(IPAddress.None, 0)), "TcpServerPort")
        {
            serverEPConfig = serverPortEndpointConfig;

            PortBehavior = new PortBehaviorStorage()
            {
                DataDeliveryBehavior = DataDeliveryBehavior.ByteStream, IsNetworkPort = true, IsServerPort = true
            };
        }
Exemple #2
0
        public TcpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig, string className)
            : base(portConfig, className)
        {
            targetEPConfig = ipPortEndpointConfig;

            PortBehavior = new PortBehaviorStorage()
            {
                DataDeliveryBehavior = DataDeliveryBehavior.ByteStream, IsNetworkPort = true, IsClientPort = true
            };

            PrivateBaseState = new BaseState(false, true);
            PublishBaseState("object constructed");
        }
Exemple #3
0
        public static bool TryParse(ref Utils.StringScanner specScanRef, out IPPortEndpointConfig ipPortEndpointConfig)
        {
            Utils.StringScanner specScan = specScanRef;
            string    ec              = null;
            string    elementName     = null;
            string    addrAttribValue = string.Empty;
            int       portAttribValue = 0;
            IPAddress ipAddr          = null;

            if (!specScan.MatchToken("<", true, false) ||
                !specScan.ExtractToken(out elementName, TokenType.AlphaNumeric, false, true, false))
            {
                ec = Utils.Fcns.CheckedFormat("Could not find element name in SpecStr:'{0}'", specScan.Str);
            }
            else if (specScan.Rest.StartsWith("addr=") && !specScan.ParseXmlAttribute("addr", out addrAttribValue))
            {
                ec = Utils.Fcns.CheckedFormat("Could not extract addr attribute from SpecStr:'{0}'", specScan.Str);
            }
            else if (!specScan.ParseXmlAttribute("port", out portAttribValue))
            {
                ec = Utils.Fcns.CheckedFormat("Could not extract port attribute from SpecStr:'{0}'", specScan.Str);
            }
            else if (!specScan.MatchToken("/>", true, false))
            {
                ec = Utils.Fcns.CheckedFormat("Did not find expected element end in SpecStr:'{0}'", specScan.Str);
            }
            else if (!CannedIPAddresses.TryGetValue(addrAttribValue ?? String.Empty, out ipAddr) &&
                     !IPAddress.TryParse(addrAttribValue, out ipAddr))
            {
                ec = Utils.Fcns.CheckedFormat("valid IPAddress could not be extracted from addr attribute:'{0}' in SpecStr:'{1}'", addrAttribValue, specScan.Str);
            }

            if (ec == null)
            {
                // successfull parse
                ec          = string.Empty;
                specScanRef = specScan;
            }

            if (ipAddr == null)
            {
                ipAddr = IPAddress.None;
            }

            ipPortEndpointConfig = new IPPortEndpointConfig(elementName, new IPEndPoint(ipAddr, portAttribValue), ec);

            return(ipPortEndpointConfig.IsValid);
        }
Exemple #4
0
        public TcpServerPort(PortConfig portConfig, IPPortEndpointConfig serverPortEndpointConfig)
            : base(portConfig, new IPPortEndpointConfig("", new IPEndPoint(IPAddress.None, 0)), "TcpServerPort")
        {
            serverEPConfig = serverPortEndpointConfig;

            PortBehavior = new PortBehaviorStorage() { DataDeliveryBehavior = DataDeliveryBehavior.ByteStream, IsNetworkPort = true, IsServerPort = true };
        }
Exemple #5
0
 public static IPort CreateTcpServerPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
 {
     return new TcpServerPort(portConfig, ipPortEndpointConfig);
 }
Exemple #6
0
        public TcpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig, string className)
            : base(portConfig, className)
        {
            targetEPConfig = ipPortEndpointConfig;

            PortBehavior = new PortBehaviorStorage() { DataDeliveryBehavior = DataDeliveryBehavior.ByteStream, IsNetworkPort = true, IsClientPort = true };

            PrivateBaseState = new BaseState(false, true);
            PublishBaseState("object constructed");
        }
Exemple #7
0
 public TcpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
     : this(portConfig, ipPortEndpointConfig, "TcpClientPort")
 {
 }
Exemple #8
0
        public static bool TryParse(ref Utils.StringScanner specScanRef, out IPPortEndpointConfig ipPortEndpointConfig)
        {
            Utils.StringScanner specScan = specScanRef;
            string ec = null;
            string elementName = null;
            string addrAttribValue = string.Empty;
            int portAttribValue = 0;
            IPAddress ipAddr = null;

            if (!specScan.MatchToken("<", true, false)
                || !specScan.ExtractToken(out elementName, TokenType.AlphaNumeric, false, true, false))
            {
                ec = Utils.Fcns.CheckedFormat("Could not find element name in SpecStr:'{0}'", specScan.Str);
            }
            else if (specScan.Rest.StartsWith("addr=") && !specScan.ParseXmlAttribute("addr", out addrAttribValue))
            {
                ec = Utils.Fcns.CheckedFormat("Could not extract addr attribute from SpecStr:'{0}'", specScan.Str);
            }
            else if (!specScan.ParseXmlAttribute("port", out portAttribValue))
            {
                ec = Utils.Fcns.CheckedFormat("Could not extract port attribute from SpecStr:'{0}'", specScan.Str);
            }
            else if (!specScan.MatchToken("/>", true, false))
            {
                ec = Utils.Fcns.CheckedFormat("Did not find expected element end in SpecStr:'{0}'", specScan.Str);
            }
            else if (!CannedIPAddresses.TryGetValue(addrAttribValue ?? String.Empty, out ipAddr)
                        && !IPAddress.TryParse(addrAttribValue, out ipAddr))
            {
                ec = Utils.Fcns.CheckedFormat("valid IPAddress could not be extracted from addr attribute:'{0}' in SpecStr:'{1}'", addrAttribValue, specScan.Str);
            }

            if (ec == null)
            {
                // successfull parse
                ec = string.Empty;
                specScanRef = specScan;
            }

            if (ipAddr == null)
                ipAddr = IPAddress.None;

            ipPortEndpointConfig = new IPPortEndpointConfig(elementName, new IPEndPoint(ipAddr, portAttribValue), ec);

            return ipPortEndpointConfig.IsValid;
        }
Exemple #9
0
 public static IPort CreateTcpServerPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
 {
     return(new TcpServerPort(portConfig, ipPortEndpointConfig));
 }
Exemple #10
0
 public TcpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig) : this(portConfig, ipPortEndpointConfig, "TcpClientPort")
 {
 }
Exemple #11
0
 /// <summary>
 /// static factory method used to create a UdpClientPort from the given portConfig and ipPortEndpointConfig
 /// </summary>
 public static IPort CreateUdpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
 {
     return new UdpClientPort(portConfig, ipPortEndpointConfig);
 }
Exemple #12
0
 /// <summary>
 /// Standard constructor.  Accepts PortConfig and IPPortEndpointConfig (parsed from PortConfig.SpecStr).
 /// </summary>
 public UdpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
     : base(portConfig, ipPortEndpointConfig, "UdpClientPort")
 {
 }
Exemple #13
0
 /// <summary>
 /// Standard constructor.  Accepts PortConfig and IPPortEndpointConfig (parsed from PortConfig.SpecStr).
 /// </summary>
 public UdpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
     : base(portConfig, ipPortEndpointConfig, "UdpClientPort")
 {
 }
Exemple #14
0
 /// <summary>
 /// static factory method used to create a UdpClientPort from the given portConfig and ipPortEndpointConfig
 /// </summary>
 public static IPort CreateUdpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
 {
     return(new UdpClientPort(portConfig, ipPortEndpointConfig));
 }