Exemple #1
0
        internal static Socket GetAConnectedSocket()
        {
            Socket s = SocketPair.GetConnectedSocket();

            Debug.Assert(s != null);
            Debug.Assert(s.Connected);
            return(s);
        }
Exemple #2
0
        //--------
        internal static Socket GetConnectedSocket()
        {
            // No need for locking etc here, as it's ok to make one or more (not
            // many hopefully however!)  The socket (is meant!) to be only used on
            // initialising the base NetworkStream, so it doesn't matter if the
            // SocketPair is finalized either.  Better to create only one, hence
            // why we cache it.
            // Careful of a race between accessing it, it becoming null, and the
            // Finalizer running, so keep a reference locally.
            SocketPair sp = m_SocketPair;

            if (sp == null || !sp.Alive)
            {
                m_SocketPair = sp = SocketPair.Create();
            }
            return(sp.m_cli);
        }