sockscape/server/Socks/MasterUdpServer.cs

45 lines
1.1 KiB
C#
Raw Normal View History

2017-06-16 21:00:01 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
2017-07-22 19:27:41 +00:00
namespace SockScape.Socks {
2017-06-16 21:00:01 +00:00
static class MasterUdpServer {
private static UdpClient Sock;
2017-08-21 21:03:32 +00:00
private static Thread ListeningThread;
private static bool IsOpen;
2017-06-16 21:00:01 +00:00
public static void Initialize() {
if(!IsOpen && ListeningThread == null)
return;
short port = (short)Configuration.General["Master Port"];
Sock = new UdpClient(port);
IsOpen = true;
2017-08-21 21:03:32 +00:00
ListeningThread = new Thread(Listener);
2017-06-16 21:00:01 +00:00
ListeningThread.Start();
}
public static void Listener() {
while(IsOpen) {
while(Sock.Available > 0) {
2017-06-16 21:00:01 +00:00
}
Thread.Sleep(1);
}
}
public static void Close() {
IsOpen = false;
ListeningThread.Join();
ListeningThread = null;
}
}
}