mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-14 21:24:34 +01:00
logger & tcp server
This commit is contained in:
34
Gameserver/Server.cs
Normal file
34
Gameserver/Server.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user