System.Net.Sockets.Socket.SetToConnected C# (CSharp) Method

SetToConnected() private method

private SetToConnected ( ) : void
return void
        internal void SetToConnected()
        {
            if (_isConnected)
            {
                // Socket was already connected.
                return;
            }

            // Update the status: this socket was indeed connected at
            // some point in time update the perf counter as well.
            _isConnected = true;
            _isDisconnected = false;
            if (NetEventSource.IsEnabled) NetEventSource.Info(this, "now connected");
            if (s_perfCountersEnabled)
            {
                SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketConnectionsEstablished);
            }
        }

Usage Example

示例#1
0
        internal override object PostCompletion(int numBytes)
        {
            SocketError errorCode   = (SocketError)base.ErrorCode;
            Socket      asyncObject = (Socket)base.AsyncObject;

            if (errorCode == SocketError.Success)
            {
                try
                {
                    errorCode = UnsafeNclNativeMethods.OSSOCK.setsockopt(asyncObject.SafeHandle, SocketOptionLevel.Socket, SocketOptionName.UpdateConnectContext, (byte[])null, 0);
                    if (errorCode == SocketError.SocketError)
                    {
                        errorCode = (SocketError)Marshal.GetLastWin32Error();
                    }
                }
                catch (ObjectDisposedException)
                {
                    errorCode = SocketError.OperationAborted;
                }
                base.ErrorCode = (int)errorCode;
            }
            if (errorCode == SocketError.Success)
            {
                asyncObject.SetToConnected();
                return(asyncObject);
            }
            return(null);
        }
All Usage Examples Of System.Net.Sockets.Socket::SetToConnected