using System;
using System.Threading;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Text.RegularExpressions;
namespace HTTPThreadedServer
{
class HTTPServ
{
private static String rootDir = "c:\\webtest";
public static void process(Socket handler)
{
Console.WriteLine("I recieved a connection and spawned a thread.");
return;
}
public static void Main(String[] args)
{
Console.WriteLine("HTTPServer version 0.1");
Console.WriteLine("Arguments: port (default is 80)");
Int32 port = 80;
if (args.Length > 0)
port = Convert.ToInt32(args[0]);
IPEndPoint localEP = new IPEndPoint(IPAddress.Any, port);
Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
listener.Bind(localEP);
while (true)
{
listener.Listen(4);
Socket handler = listener.Accept();
ThreadStart ts = new ThreadStart(threadProcess.proc);
}
}
}
}