从防火墙"stonegate"获取消息到系统日志服务器 [英] get message from firewall "stonegate" to syslog srerver

查看:127
本文介绍了从防火墙"stonegate"获取消息到系统日志服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace ConsoleApplication3
{
    class Program
    {
        private static void Main()
        {
            string IP = "127.0.0.1";
            int port = 514;

            IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(IP), port);

            Thread receiveThread = new Thread(ReceiveData);
            receiveThread.IsBackground = true;
            receiveThread.Start();

            UdpClient client = new UdpClient();

            try
            {
                string text;
                do
                {
                    text = Console.ReadLine();

                    if (text.Length != 0)
                    {
                        byte[] data = Encoding.UTF8.GetBytes(text);
                        client.Send(data, data.Length, remoteEndPoint);
                    }
                } while (text.Length != 0);
            }
            catch (Exception err)
            {
                Console.WriteLine(err.ToString());
            }
            finally
            {
                client.Close();
            }
        }

        private static void ReceiveData()
        {
            UdpClient client = new UdpClient(514);
            while (true)
            {
                try
                {
                    IPEndPoint anyIP = new IPEndPoint(IPAddress.Any, 0);
                    byte[] data = client.Receive(ref anyIP);
                    string text = Encoding.UTF8.GetString(data);
                    Console.WriteLine(">> " + text);
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.ToString());
                }
            }
        }
    }
}

推荐答案

要获取帮助,只需在以下位置找到它: ^ ]

我们可以帮助您解决编程问题,而无需设置StoneSoft软件.
To get help, just find it at: https://my.stonesoft.com/support/browse.do?product=StoneGate&browsetype=subject&selection=Authentication[^]

We can help you with programming question, not setting the StoneSoft software.


这篇关于从防火墙"stonegate"获取消息到系统日志服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆