• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SocketOptionLevel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SocketOptionLevel的典型用法代码示例。如果您正苦于以下问题:C# SocketOptionLevel类的具体用法?C# SocketOptionLevel怎么用?C# SocketOptionLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SocketOptionLevel类属于命名空间,在下文中一共展示了SocketOptionLevel类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SetSocketOption

 protected static int SetSocketOption(Socket socket, SocketOptionLevel level, SocketOptionName name, int value)
 {
     if (((int)socket.GetSocketOption(level, name)) == value)
         return value;
     socket.SetSocketOption(level, name, value);
     return (int)socket.GetSocketOption(level, name);
 }
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:7,代码来源:NetworkUtils.cs


示例2: SetSocketOption

 protected void SetSocketOption(SocketOptionLevel level, SocketOptionName name, int option)
 {
     try
     {
         m_sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, option);
     }
     catch { }
 }
开发者ID:x893,项目名称:SharpSSH,代码行数:8,代码来源:Socket.cs


示例3: SetSocketOption

		protected static bool SetSocketOption(Socket socket, SocketOptionLevel level, SocketOptionName name, bool value) {
			if (((int)socket.GetSocketOption(level, name)) == (value ? 1 : 0))
				return value;
			socket.SetSocketOption(level, name, value);
			if (((int)socket.GetSocketOption(level, name)) != 1) {
				return false;
			}
			return true;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:9,代码来源:NetworkUtils.cs


示例4: SetSocketOption

		protected void SetSocketOption(SocketOptionLevel level, SocketOptionName name, int val)
		{
			try
			{
				sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, val);
			}
			catch
			{
			}
		}
开发者ID:MatanDavidCohen,项目名称:StockAnalyzerWin,代码行数:10,代码来源:Socket.cs


示例5: SetSockOpt

 internal static unsafe Error SetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int optionLen)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousSetSockOpt((int)socket.DangerousGetHandle(), optionLevel, optionName, optionValue, optionLen);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.SetSockOpt.cs


示例6: SetSocketOption

        public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, bool optionValue)
        {

            if (optionName == SocketOptionName.ReuseAddress)
            {
                if (this.InternalServerSocket != null)
                {
                    try
                    {
                        //Console.WriteLine("setReuseAddress... " + new { optionValue });

                        this.InternalServerSocket.setReuseAddress(optionValue);
                    }
                    catch
                    {
                        throw;
                    }
                }
            }
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:20,代码来源:Socket.cs


示例7: MulticastPolicyServerCore

        public MulticastPolicyServerCore(AddressFamily addressFamily, MulticastPolicyConfiguration configuration)
        {
            Debug.Assert(configuration != null, "Configuration should not be null");

            this.addressFamily = addressFamily;
            this.configuration = configuration;

            if (addressFamily == AddressFamily.InterNetwork)
            {
                this.localEndPoint = new IPEndPoint(IPAddress.Any, MulticastPolicyPort);
                this.socketOptionLevel = SocketOptionLevel.IP;
            }
            else
            {
                this.localEndPoint = new IPEndPoint(IPAddress.IPv6Any, MulticastPolicyPort);
                this.socketOptionLevel = SocketOptionLevel.IPv6;
            }

            SetMulticastSocketFactory(new RealMulticastSocketFactory());
        }
开发者ID:JackNova,项目名称:SilverlightNetworkingUDP,代码行数:20,代码来源:MulticastPolicyServerCore.cs


示例8: SetSocketOption

        internal unsafe void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue, bool silent)
        {
            GlobalLog.Print("Socket#" + Logging.HashString(this) + "::SetSocketOption() optionLevel:" + optionLevel + " optionName:" + optionName + " optionValue:" + optionValue + " silent:" + silent);
            if (silent && (CleanedUp || _handle.IsInvalid))
            {
                GlobalLog.Print("Socket#" + Logging.HashString(this) + "::SetSocketOption() skipping the call");
                return;
            }
            SocketError errorCode = SocketError.Success;
            try
            {
                errorCode = SocketPal.SetSockOpt(_handle, optionLevel, optionName, optionValue);

                GlobalLog.Print("Socket#" + Logging.HashString(this) + "::SetSocketOption() Interop.Winsock.setsockopt returns errorCode:" + errorCode);
            }
            catch
            {
                if (silent && _handle.IsInvalid)
                {
                    return;
                }
                throw;
            }

            // Keep the internal state in sync if the user manually resets this.
            if (optionName == SocketOptionName.PacketInformation && optionValue == 0 &&
                errorCode == SocketError.Success)
            {
                _receivingPacketInformation = false;
            }

            if (silent)
            {
                return;
            }

            // Throw an appropriate SocketException if the native call fails.
            if (errorCode != SocketError.Success)
            {
                // Update the internal state of this socket according to the error before throwing.
                SocketException socketException = new SocketException((int)errorCode);
                UpdateStatusAfterSocketError(socketException);
                if (s_loggingEnabled)
                {
                    Logging.Exception(Logging.Sockets, this, "SetSocketOption", socketException);
                }
                throw socketException;
            }
        }
开发者ID:ReedKimble,项目名称:corefx,代码行数:49,代码来源:Socket.cs


示例9: SetSocketOption_internal

		extern static void SetSocketOption_internal (IntPtr socket, SocketOptionLevel level, SocketOptionName name, object obj_val, byte [] byte_val, int int_val, out int error);
开发者ID:Profit0004,项目名称:mono,代码行数:1,代码来源:Socket.cs


示例10: SetSocketOption

		public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, byte [] optionValue)
		{
			if (disposed && closed)
				throw new ObjectDisposedException (GetType ().ToString ());

			// I'd throw an ArgumentNullException, but this is what MS does.
			if (optionValue == null)
				throw new SocketException ((int) SocketError.Fault,
					"Error trying to dereference an invalid pointer");
			
			int error;

			SetSocketOption_internal (socket, optionLevel, optionName, null,
						 optionValue, 0, out error);

			if (error != 0) {
				if (error == (int) SocketError.InvalidArgument)
					throw new ArgumentException ();
				throw new SocketException (error);
			}
		}
开发者ID:frje,项目名称:SharpLang,代码行数:21,代码来源:Socket.cs


示例11: SetSocketOption

		public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue)
		{
			ThrowIfDisposedAndClosed ();

			// NOTE: if a null is passed, the byte[] overload is used instead...
			if (optionValue == null)
				throw new ArgumentNullException("optionValue");

			int error;

			if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.Linger) {
				LingerOption linger = optionValue as LingerOption;
				if (linger == null)
					throw new ArgumentException ("A 'LingerOption' value must be specified.", "optionValue");
				SetSocketOption_internal (safe_handle, optionLevel, optionName, linger, null, 0, out error);
			} else if (optionLevel == SocketOptionLevel.IP && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) {
				MulticastOption multicast = optionValue as MulticastOption;
				if (multicast == null)
					throw new ArgumentException ("A 'MulticastOption' value must be specified.", "optionValue");
				SetSocketOption_internal (safe_handle, optionLevel, optionName, multicast, null, 0, out error);
			} else if (optionLevel == SocketOptionLevel.IPv6 && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) {
				IPv6MulticastOption multicast = optionValue as IPv6MulticastOption;
				if (multicast == null)
					throw new ArgumentException ("A 'IPv6MulticastOption' value must be specified.", "optionValue");
				SetSocketOption_internal (safe_handle, optionLevel, optionName, multicast, null, 0, out error);
			} else {
				throw new ArgumentException ("Invalid value specified.", "optionValue");
			}

			if (error != 0) {
				if (error == (int) SocketError.InvalidArgument)
					throw new ArgumentException ();
				throw new SocketException (error);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:35,代码来源:Socket.cs


示例12: GetSocketOption_obj_internal

		extern static void GetSocketOption_obj_internal(IntPtr socket, SocketOptionLevel level, SocketOptionName name, out object obj_val, out int error);
开发者ID:Profit0004,项目名称:mono,代码行数:1,代码来源:Socket.cs


示例13: GetSocketOption

		public object GetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName)
		{
			ThrowIfDisposedAndClosed ();

			int error;
			object obj_val;
			GetSocketOption_obj_internal (safe_handle, optionLevel, optionName, out obj_val, out error);

			if (error != 0)
				throw new SocketException (error);

			if (optionName == SocketOptionName.Linger)
				return (LingerOption) obj_val;
			else if (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)
				return (MulticastOption) obj_val;
			else if (obj_val is int)
				return (int) obj_val;
			else
				return obj_val;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:20,代码来源:Socket.cs


示例14: numericOption

 private int numericOption(SocketOptionLevel optionLevel, SocketOptionName optionName) {
     return (int)Client.GetSocketOption(optionLevel, optionName);
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:3,代码来源:tcpclient.cs


示例15: GetSocketOption_arr_internal

		extern static void GetSocketOption_arr_internal(IntPtr socket, SocketOptionLevel level, SocketOptionName name, ref byte[] byte_val, out int error);
开发者ID:Profit0004,项目名称:mono,代码行数:1,代码来源:Socket.cs


示例16: GetSocketOption

        // Gets the value of a socket option.
        public object GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName)
        {
            if (CleanedUp)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.Linger)
            {
                return GetLingerOpt();
            }
            else if (optionLevel == SocketOptionLevel.IP && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership))
            {
                return GetMulticastOpt(optionName);
            }
            else if (optionLevel == SocketOptionLevel.IPv6 && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership))
            {
                // Handle IPv6 case
                return GetIPv6MulticastOpt(optionName);
            }

            int optionValue = 0;

            // This can throw ObjectDisposedException.
            SocketError errorCode = SocketPal.GetSockOpt(
                _handle,
                optionLevel,
                optionName,
                out optionValue);

            GlobalLog.Print("Socket#" + Logging.HashString(this) + "::GetSocketOption() Interop.Winsock.getsockopt returns errorCode:" + errorCode);

            // Throw an appropriate SocketException if the native call fails.
            if (errorCode != SocketError.Success)
            {
                // Update the internal state of this socket according to the error before throwing.
                SocketException socketException = new SocketException((int)errorCode);
                UpdateStatusAfterSocketError(socketException);
                if (s_loggingEnabled)
                {
                    Logging.Exception(Logging.Sockets, this, "GetSocketOption", socketException);
                }
                throw socketException;
            }

            return optionValue;
        }
开发者ID:ReedKimble,项目名称:corefx,代码行数:47,代码来源:Socket.cs


示例17: SetSocketOption

 internal void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue)
 {
     internalSocket.SetSocketOption(optionLevel, optionName, optionValue);
 }
开发者ID:Borvik,项目名称:Winsock.Net,代码行数:4,代码来源:AsyncSocket.cs


示例18: CheckSetOptionPermissions

 private void CheckSetOptionPermissions(SocketOptionLevel optionLevel, SocketOptionName optionName)
 {
     // Freely allow only the options listed below.
     if (!(optionLevel == SocketOptionLevel.Tcp &&
           (optionName == SocketOptionName.NoDelay ||
            optionName == SocketOptionName.BsdUrgent ||
            optionName == SocketOptionName.Expedited))
           &&
           !(optionLevel == SocketOptionLevel.Udp &&
             (optionName == SocketOptionName.NoChecksum ||
              optionName == SocketOptionName.ChecksumCoverage))
           &&
           !(optionLevel == SocketOptionLevel.Socket &&
           (optionName == SocketOptionName.KeepAlive ||
            optionName == SocketOptionName.Linger ||
            optionName == SocketOptionName.DontLinger ||
            optionName == SocketOptionName.SendBuffer ||
            optionName == SocketOptionName.ReceiveBuffer ||
            optionName == SocketOptionName.SendTimeout ||
            optionName == SocketOptionName.ExclusiveAddressUse ||
            optionName == SocketOptionName.ReceiveTimeout))
           &&
           !(optionLevel == SocketOptionLevel.IPv6 &&
             optionName == (SocketOptionName)23)) // IPv6 protection level.
     {
     }
 }
开发者ID:ReedKimble,项目名称:corefx,代码行数:27,代码来源:Socket.cs



注:本文中的SocketOptionLevel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SocketOptionName类代码示例发布时间:2022-05-24
下一篇:
C# SocketOperation类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap