예제 #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
            };
        }
예제 #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");
        }
예제 #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);
        }
예제 #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 };
        }
예제 #5
0
 public static IPort CreateTcpServerPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
 {
     return new TcpServerPort(portConfig, ipPortEndpointConfig);
 }
예제 #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");
        }
예제 #7
0
 public TcpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
     : this(portConfig, ipPortEndpointConfig, "TcpClientPort")
 {
 }
예제 #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;
        }
예제 #9
0
 public static IPort CreateTcpServerPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
 {
     return(new TcpServerPort(portConfig, ipPortEndpointConfig));
 }
예제 #10
0
 public TcpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig) : this(portConfig, ipPortEndpointConfig, "TcpClientPort")
 {
 }
예제 #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);
 }
예제 #12
0
 /// <summary>
 /// Standard constructor.  Accepts PortConfig and IPPortEndpointConfig (parsed from PortConfig.SpecStr).
 /// </summary>
 public UdpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
     : base(portConfig, ipPortEndpointConfig, "UdpClientPort")
 {
 }
예제 #13
0
 /// <summary>
 /// Standard constructor.  Accepts PortConfig and IPPortEndpointConfig (parsed from PortConfig.SpecStr).
 /// </summary>
 public UdpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig)
     : base(portConfig, ipPortEndpointConfig, "UdpClientPort")
 {
 }
예제 #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));
 }