ASCU_ALL/Test2/Program.cs
2021-05-28 20:51:55 +05:00

56 lines
1.2 KiB
C#

using System;
using NLog;
using NLog.Config;
using NLog.Targets;
using DataClient;
using System.Net.Sockets;
using System.Net;
using System.Collections.Generic;
using System.Text;
namespace Test2
{
class Program
{
static void Main(string[] args)
{
LogConf();
var test = new STPClient();
Console.WriteLine("Hello World!");
}
static void LogConf()
{
var conf = new LoggingConfiguration();
var logcon = new ColoredConsoleTarget()
{
Name = "logcon",
Layout = @"${time}|${level:uppercase=true}|${logger}|${message}${when:when=length('${exception}')>0:Inner=|}${exception:format=ToString,StackTrace}"
};
conf.AddRule(LogLevel.Trace, LogLevel.Fatal, logcon);
LogManager.Configuration = conf;
}
static void testSocket()
{
Socket s = null;
IPEndPoint ipe = new IPEndPoint(IPAddress.Parse("10.10.45.152"), 1070);
s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var code = "slit history";
var send = new List<byte>();
for (var i = 0; i < 4; i++)
send.Add(0xff);
send.AddRange(BitConverter.GetBytes((uint)code.Length));
send.AddRange(Encoding.ASCII.GetBytes(code));
send.Add(0x00);
s.Connect(ipe);
s.Send(send.ToArray());
s.Available;
}
}
}