logger & tcp server

This commit is contained in:
rafi1212122
2023-05-25 21:46:59 +07:00
parent f294d9faa4
commit 358b2b7cca
6 changed files with 141 additions and 11 deletions

34
Gameserver/Server.cs Normal file
View File

@@ -0,0 +1,34 @@
using System.Net.Sockets;
using System.Net;
using Common;
using Common.Utils;
namespace PemukulPaku.Gameserver
{
public class Server
{
public static Logger c = new("TCP", ConsoleColor.Blue);
public static void Start()
{
TcpListener Listener = new(IPAddress.Parse("0.0.0.0"), (int)Global.config.Gameserver.Port);
try
{
Listener.Start();
c.Log($"TCP server started on port {Global.config.Gameserver.Port}");
while (true)
{
TcpClient Client = Listener.AcceptTcpClient();
c.Warn($"{Client.Client.RemoteEndPoint} connected!");
NetworkStream stream = Client.GetStream();
}
}
catch (Exception ex)
{
c.Error("TCP server error: " + ex.Message);
}
}
}
}