Beispiel #1
0
        internal bool CallEndPointDelegate(Socket sock, IPEndPoint remote)
        {
            if (endPointCallback == null)
            {
                return(true);
            }

            int count = 0;

            for (;;)
            {
                IPEndPoint local = null;
                try
                {
                    local = endPointCallback(this, remote, count);
                }
                catch
                {
                    // This is to differentiate from an
                    // OverflowException, which should propagate.
                    return(false);
                }

                if (local == null)
                {
                    return(true);
                }

#if SSHARP
                return(false);
#else
                try
                {
                    //sock.LocalEndPoint = local;
                    sock.Bind(local);
                }
                catch (SocketException)
                {
                    // This is intentional; the docs say
                    // that if the Bind fails, we keep
                    // going until there is an
                    // OverflowException on the retry
                    // count.
                    checked
                    {
                        ++count;
                    }
                    continue;
                }

                return(true);
#endif
            }
        }
Beispiel #2
0
        internal void KeepAliveSetup(Socket socket)
        {
#if SSHARP
#else
            if (!tcp_keepalive)
            {
                return;
            }

            byte[] bytes = new byte[12];
            PutBytes(bytes, (uint)(tcp_keepalive ? 1 : 0), 0);
            PutBytes(bytes, (uint)tcp_keepalive_time, 4);
            PutBytes(bytes, (uint)tcp_keepalive_interval, 8);
            socket.IOControl(IOControlCode.KeepAliveValues, bytes, null);
#endif
        }
Beispiel #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="socket">Socket opened with the client</param>
        public MqttNetworkChannel(Socket socket)
#if !(MF_FRAMEWORK_VERSION_V4_2 || MF_FRAMEWORK_VERSION_V4_3 || COMPACT_FRAMEWORK) || SSHARP
            : this(socket, false, null, MqttSslProtocols.None, null, null)
#else
            : this(socket, false, null, MqttSslProtocols.None)