System.Runtime.Remoting.Channels.CachedSocketList.GetSocket C# (CSharp) Method

GetSocket() private method

private GetSocket ( ) : SocketHandler
return SocketHandler
        internal SocketHandler GetSocket()
        {
            if (_socketCount == 0)
                return null;
        
            lock (this)
            {    
                if (_socketList != null)
                {
                    SocketHandler socket = _socketList.Handler;
                    _socketList = _socketList.Next;

                    bool bRes = socket.RaceForControl();

                    // We should always have control since there shouldn't
                    //   be contention here.
                    InternalRemotingServices.RemotingAssert(bRes, "someone else has the socket?");

                    _socketCount--;
                    return socket;
                }                                      
            }

            return null;
        } // GetSocket

Usage Example

        } // RemoteConnection

        internal SocketHandler GetSocket()
        {
            // try the cached socket list
            SocketHandler socketHandler = _cachedSocketList.GetSocket();

            if (socketHandler != null)
            {
                return(socketHandler);
            }

            // Otherwise, we'll just create a new one.
            return(CreateNewSocket());
        } // GetSocket