Beispiel #1
0
        void FireOnDataWaitingEvent(byte[] bytes)
        {
            TcpSocketEventArgs evArgs = new TcpSocketEventArgs();

            if (OnDataWaiting != null)
            {
                evArgs.Bytes = bytes;
                OnDataWaiting(this, evArgs);
            }
            else
            {
                Exception ex = new TcpSocketException(TcpSocketExceptionType.GeneralException, "There is no event handler defined for OnDataWaiting.");
                throw (ex);
            }
        }
Beispiel #2
0
        void FireOnErrorEvent(TcpSocketExceptionType exceptionType, string errorMessage)
        {
            TcpSocketEventArgs evArgs = new TcpSocketEventArgs();

            if (OnError != null)
            {
                evArgs.Error = errorMessage;
                OnError(this, evArgs);
            }
            else
            {
                Exception ex = new TcpSocketException(TcpSocketExceptionType.GeneralException, "There is no event handler defined for OnError.");
                throw (ex);
            }
        }
Beispiel #3
0
        void FireOnTerminatedEvent(string message)
        {
            if (rawIpSocket != null)
            {
                rawIpSocket.Close();
            }

            TcpSocketEventArgs evArgs = new TcpSocketEventArgs()
            {
                Error = message
            };

            if (OnTerminated != null)
            {
                OnTerminated(this, evArgs);
            }
            else
            {
                Exception ex = new TcpSocketException(TcpSocketExceptionType.GeneralException, "There is no event handler defined for OnTerminated.");
                throw (ex);
            }
        }