当前位置: 首页>>代码示例>>C#>>正文


C# SocketShutdown类代码示例

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


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

示例1: InternalShutdown

		// don't change for default, otherwise breaking change

		// this version does not throw.
		internal void InternalShutdown (SocketShutdown how)
		{
			if (!is_connected || is_disposed)
				return;
			int error;
			Shutdown_internal (safe_handle, how, out error);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:10,代码来源:Socket.cs

示例2: InternalShutdown

		// don't change for default, otherwise breaking change

		// this version does not throw.
		internal void InternalShutdown (SocketShutdown how)
		{
			if (!connected || disposed)
				return;
			int error;
			Shutdown_internal (socket, how, out error);
		}
开发者ID:kumpera,项目名称:mono,代码行数:10,代码来源:Socket.cs

示例3: InternalShutdown

		// don't change for default, otherwise breaking change

		// this version does not throw.
		internal void InternalShutdown (SocketShutdown how)
		{
			if (!is_connected || CleanedUp)
				return;
			int error;
			Shutdown_internal (m_Handle, how, out error);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:10,代码来源:Socket.cs

示例4: Shutdown

 internal static Error Shutdown(SafeHandle socket, SocketShutdown how)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousShutdown((int)socket.DangerousGetHandle(), how);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.Shutdown.cs

示例5: Shutdown_internal

		internal extern static void Shutdown_internal (IntPtr socket, SocketShutdown how, out int error);
开发者ID:Profit0004,项目名称:mono,代码行数:1,代码来源:Socket.cs

示例6: Shutdown

		public void Shutdown (SocketShutdown how)
		{
			ThrowIfDisposedAndClosed ();

			if (!is_connected)
				throw new SocketException (10057); // Not connected

			int error;
			Shutdown_internal (safe_handle, how, out error);

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

示例7: Shutdown

        // Disables sends and receives on a socket.
        public void Shutdown(SocketShutdown how)
        {
            if (s_loggingEnabled)
            {
                Logging.Enter(Logging.Sockets, this, "Shutdown", how);
            }
            if (CleanedUp)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            GlobalLog.Print("Socket#" + Logging.HashString(this) + "::Shutdown() how:" + how.ToString());

            // This can throw ObjectDisposedException.
            SocketError errorCode = SocketPal.Shutdown(_handle, _isConnected, _isDisconnected, how);

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

            // Skip good cases: success, socket already closed.
            if (errorCode != SocketError.Success && errorCode != SocketError.NotSocket)
            {
                // 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, "Shutdown", socketException);
                }
                throw socketException;
            }

            SetToDisconnected();
            InternalSetBlocking(_willBlockInternal);
            if (s_loggingEnabled)
            {
                Logging.Exit(Logging.Sockets, this, "Shutdown", "");
            }
        }
开发者ID:ReedKimble,项目名称:corefx,代码行数:39,代码来源:Socket.cs

示例8: Shutdown

		public void Shutdown (SocketShutdown how)
		{
			if (disposed && closed)
				throw new ObjectDisposedException (GetType ().ToString ());

			if (!connected)
				throw new SocketException (10057); // Not connected

			int error;
			
			Shutdown_internal (socket, how, out error);
			if (error != 0)
				throw new SocketException (error);
		}
开发者ID:telurmasin,项目名称:mono,代码行数:14,代码来源:Socket_2_1.cs

示例9: SafeSetSocketTimeout

        private void SafeSetSocketTimeout(SocketShutdown mode) {

            if(Eof){
                return;
            }

            int timeout;
            if (mode == SocketShutdown.Receive) {
                timeout = ReadTimeout;
            } else /*if (mode == SocketShutdown.Send)*/ {
                timeout = WriteTimeout;
            }
            Connection connection = m_Connection;
            if (connection!=null) {
                NetworkStream networkStream = connection.NetworkStream;
                if (networkStream!=null) {
                    networkStream.SetSocketTimeoutOption(mode, timeout, false);
                }
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:20,代码来源:_ConnectStream.cs

示例10: SetSocketTimeoutOption

        internal void SetSocketTimeoutOption(SocketShutdown mode, int timeout, bool silent) {
            GlobalLog.Print("NetworkStream#" + ValidationHelper.HashString(this) + "::SetSocketTimeoutOption() mode:" + mode + " silent:" + silent + " timeout:" + timeout + " m_CurrentReadTimeout:" + m_CurrentReadTimeout + " m_CurrentWriteTimeout:" + m_CurrentWriteTimeout);
            GlobalLog.ThreadContract(ThreadKinds.Unknown, "NetworkStream#" + ValidationHelper.HashString(this) + "::SetSocketTimeoutOption");

            if (timeout < 0) {
                timeout = 0; // -1 becomes 0 for the winsock stack
            }

            Socket chkStreamSocket = m_StreamSocket;
            if (chkStreamSocket==null) {
                return;
            }
            if (mode==SocketShutdown.Send || mode==SocketShutdown.Both) {
                if (timeout!=m_CurrentWriteTimeout) {
                    chkStreamSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, timeout, silent);
                    m_CurrentWriteTimeout = timeout;
                }
            }
            if (mode==SocketShutdown.Receive || mode==SocketShutdown.Both) {
                if (timeout!=m_CurrentReadTimeout) {
                    chkStreamSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, timeout, silent);
                    m_CurrentReadTimeout = timeout;
                }
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:NetworkStream.cs

示例11: Shutdown

 public void Shutdown(SocketShutdown type)
 {
     Connection.Shutdown(type);
 }
开发者ID:faresali,项目名称:co-pserver,代码行数:4,代码来源:WinSocket.cs

示例12: SafeClose

 public static void SafeClose(this Socket socket, SocketShutdown down)
 {
     try
     {
         if (socket != null && socket.Connected)
         {
             socket.Shutdown(down);
             socket.Close();
         }
     }
     catch { }
 }
开发者ID:abel,项目名称:sinan,代码行数:12,代码来源:IPHelper.cs

示例13: ShutdownSocket

        /// <summary>
        /// Shuts down the socket.
        /// </summary>
        /// <param name="how">One of the <see cref="SocketShutdown"/> values that specifies the operation that will no longer be allowed.</param>
        private void ShutdownSocket(SocketShutdown how)
        {
#if DEBUG_GERT
            Console.WriteLine("ID: " + Thread.CurrentThread.ManagedThreadId + " | ChannelForwardedTcpip.ShutdownSocket");
#endif // DEBUG_GERT

            if (_socket == null || !_socket.Connected)
                return;

            lock (_socketShutdownAndCloseLock)
            {
                var socket = _socket;
                if (socket == null || !socket.Connected)
                    return;

                socket.Shutdown(how);
            }
        }
开发者ID:REALTOBIZ,项目名称:SSH.NET,代码行数:22,代码来源:ChannelForwardedTcpip.cs

示例14: Shutdown

 public void Shutdown(SocketShutdown how)
 {
     _remote.Shutdown(how);
 }
开发者ID:Ju2ender,项目名称:csharp-e,代码行数:4,代码来源:DirectConnect.cs

示例15: Shutdown

        public static SocketError Shutdown(SafeCloseSocket handle, bool isConnected, bool isDisconnected, SocketShutdown how)
        {
            SocketError err = Interop.Winsock.shutdown(handle, (int)how);
            if (err != SocketError.SocketError)
            {
                return SocketError.Success;
            }

            err = GetLastSocketError();
            Debug.Assert(err != SocketError.NotConnected || (!isConnected && !isDisconnected));
            return err;
        }
开发者ID:vbouret,项目名称:corefx,代码行数:12,代码来源:SocketPal.Windows.cs


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