SafeNet/.svn/pristine/bc/bc8b007fb13a01c39bfe31eab82361ceed0de9a4.svn-base
2021-02-24 13:50:23 +02:00

44 lines
1.2 KiB
Plaintext

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using SafeNetLib;
namespace PAL_SOC
{
class LocationThread
{
public int port;
private TcpListener server;
// -------------------------------------------------------------------
// Main
// -------------------------------------------------------------------
public LocationThread()
{
// init the TCP client listener
server = new TcpListener(System.Net.IPAddress.Any, Program.cfg.locPort);
server.Start();
}
public void HandleConnection()
{
while (true)
{
while (!server.Pending())
{
Thread.Sleep(1000);
}
//assign new thread for each connection
ConnectionThread newconnection = new ConnectionThread();
newconnection.client = server.AcceptTcpClient();
Thread newthread = new Thread(new ThreadStart(newconnection.HandleConnection));
newthread.IsBackground = true;
newthread.Start();
}
}
}
}