예제 #1
0
        public SocketClientSync(IPEndPoint host)
        {
            FReceivedEvent = new AutoResetEvent(false);
            FExceptionEvent = new AutoResetEvent(false);
            FSentEvent = new AutoResetEvent(false);
            FConnectEvent = new AutoResetEvent(false);
            FDisconnectEvent = new ManualResetEvent(false);

            FReceivedQueue = new Queue<string>();

            FConnectTimeout = 10000;
            FSentTimeout = 10000;

            FConnectedSync = new object();
            FConnected = false;

            FSocketClientEvents = new SocketClientSyncSocketService(this);
            FCryptClientEvents = new SocketClientSyncCryptService(this);

            FLocalEndPoint = null;
            FRemoteEndPoint = host;

            //----- Message Types!
            FEncryptType = EncryptType.etNone;
            FCompressionType = CompressionType.ctNone;
            FDelimiterType = DelimiterType.dtNone;

            //----- Proxy!
            FProxyInfo = null;

            //----- Socket delimiter and buffer size!
            FDelimiter = null;

            FMessageBufferSize = 4096;
            FSocketBufferSize = 2048;
        }
예제 #2
0
        public override void Free(bool canAccessFinalizable)
        {
            FSocketConnection = null;
            FSocketClientEvents = null;
            FCryptClientEvents = null;
            FConnectedSync = null;
            FLastException = null;

            if (FReceivedQueue != null)
            {
                FReceivedQueue.Clear();
                FReceivedQueue = null;
            }

            if (FSocketClient != null)
            {
                FSocketClient.Stop();
                FSocketClient.Dispose();
                FSocketClient = null;
            }

            if (FExceptionEvent != null)
            {
                FExceptionEvent.Close();
                FExceptionEvent = null;
            }

            if (FConnectEvent != null)
            {
                FConnectEvent.Close();
                FConnectEvent = null;
            }

            if (FSentEvent != null)
            {
                FSentEvent.Close();
                FSentEvent = null;
            }

            if (FReceivedEvent != null)
            {
                FReceivedEvent.Close();
                FReceivedEvent = null;
            }

            if (FDisconnectEvent != null)
            {
                FDisconnectEvent.Close();
                FDisconnectEvent = null;
            }

            base.Free(canAccessFinalizable);
        }