NLog.TcpClientSocket.onConnected C# (CSharp) Method

onConnected() public method

public onConnected ( IAsyncResult ar ) : void
ar IAsyncResult
return void
        void onConnected(IAsyncResult ar)
        {
            var socket = (Socket)ar.AsyncState;
            try {
                socket.EndConnect(ar);
                isConnected = true;
                IPEndPoint clientEndPoint = (IPEndPoint)socket.RemoteEndPoint;
                _log.Info(string.Format("Connected to {0}:{1}",
                    clientEndPoint.Address, clientEndPoint.Port));
                if (OnConnect != null) {
                    OnConnect(this, null);
                }
                startReceiving(socket);
            } catch (Exception ex) {
                _log.Warn(ex.Message);
                triggerOnDisconnect();
            }
        }