44 lines
1.2 KiB
Plaintext
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();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|