2023-09-02 17:56:46 +02:00
|
|
|
|
using Serilog;
|
|
|
|
|
using System.Net;
|
2023-08-29 19:36:58 +02:00
|
|
|
|
using System.Net.Sockets;
|
|
|
|
|
using System.Reflection.Metadata.Ecma335;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace server
|
2023-09-02 17:56:46 +02:00
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
public static async Task Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
using var logger = new LoggerConfiguration()
|
|
|
|
|
.WriteTo.Console()
|
|
|
|
|
.CreateLogger();
|
|
|
|
|
|
|
|
|
|
Server server = new Server(logger);
|
|
|
|
|
await server.Listen();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*namespace server
|
2023-08-29 19:36:58 +02:00
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
public static async Task Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
await Program.Listen();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async Task Listen()
|
|
|
|
|
{
|
|
|
|
|
var ipEndPoint = new IPEndPoint(IPAddress.Any, 8888);
|
|
|
|
|
TcpListener listener = new(ipEndPoint);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
listener.Start();
|
|
|
|
|
|
|
|
|
|
using TcpClient handler = await listener.AcceptTcpClientAsync();
|
|
|
|
|
await using NetworkStream stream = handler.GetStream();
|
|
|
|
|
|
|
|
|
|
stream.BeginRead(new byte[1024], 0, 1024, Callback, null);
|
|
|
|
|
|
|
|
|
|
var message = $"📅 {DateTime.Now} 🕛";
|
|
|
|
|
var dateTimeBytes = Encoding.UTF8.GetBytes(message);
|
|
|
|
|
await stream.WriteAsync(dateTimeBytes);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
listener.Stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Callback(IAsyncResult ar)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Is ocmpleted: {0}", ar.IsCompleted);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-02 17:56:46 +02:00
|
|
|
|
}*/
|