Beispiel #1
0
        private void HandleSocketOptions(XmlNode node, ClientNetworkConfig clientNetworkConfig)
        {
            SocketOptions socketOptions = clientNetworkConfig.GetSocketOptions();

            foreach (XmlNode child in node.ChildNodes)
            {
                string nodeName = CleanNodeName(child);
                switch (nodeName)
                {
                case "tcp-no-delay":
                    socketOptions.SetTcpNoDelay(Boolean.Parse(GetTextContent(child)));
                    break;

                case "keep-alive":
                    socketOptions.SetKeepAlive(Boolean.Parse(GetTextContent(child)));
                    break;

                case "reuse-address":
                    socketOptions.SetReuseAddress(Boolean.Parse(GetTextContent(child)));
                    break;

                case "linger-seconds":
                    socketOptions.SetLingerSeconds(Convert.ToInt32(GetTextContent(child)));
                    break;

                case "timeout":
                    socketOptions.SetTimeout(Convert.ToInt32(GetTextContent(child)));
                    break;

                case "buffer-size":
                    socketOptions.SetBufferSize(Convert.ToInt32(GetTextContent(child)));
                    break;
                }
            }
        }
Beispiel #2
0
        private static void HandleSocketOptions(this SocketOptions socketOptions, XmlNode node)
        {
            foreach (XmlNode child in node.ChildNodes)
            {
                var nodeName    = CleanNodeName(child);
                var textContent = GetTextContent(child);
                switch (nodeName)
                {
                case "tcp-no-delay":
                    socketOptions.TcpNoDelay = Convert.ToBoolean(textContent);
                    break;

                case "keep-alive":
                    socketOptions.KeepAlive = Convert.ToBoolean(textContent);
                    break;

                case "reuse-address":
                    socketOptions.ReuseAddress = Convert.ToBoolean(textContent);
                    break;

                case "linger-seconds":
                    socketOptions.LingerSeconds = Convert.ToInt32(textContent);
                    break;

                case "buffer-size":
                    socketOptions.BufferSize = Convert.ToInt32(textContent);
                    break;
                }
            }
        }
 public virtual ClientNetworkConfig SetSocketOptions(SocketOptions socketOptions)
 {
     _socketOptions = socketOptions;
     return this;
 }
Beispiel #4
0
 /// <summary>
 /// Sets <see cref="SocketOptions"/>
 /// </summary>
 /// <param name="socketOptions"><see cref="SocketOptions"/></param>
 /// <returns><see cref="ClientNetworkConfig"/> for chaining</returns>
 public virtual ClientNetworkConfig SetSocketOptions(SocketOptions socketOptions)
 {
     _socketOptions = socketOptions;
     return(this);
 }