mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-22 20:55:52 +12:00
Port N00BS to linux
This commit is contained in:
parent
64fed1c6c4
commit
8297c56f21
181 changed files with 282 additions and 132 deletions
30
HorseIsleServer/MPN00BS/HTTP/ContentServer.cs
Normal file → Executable file
30
HorseIsleServer/MPN00BS/HTTP/ContentServer.cs
Normal file → Executable file
|
@ -34,7 +34,6 @@ namespace HTTP
|
|||
{
|
||||
clientSock = ClientSocket;
|
||||
baseServ = Server;
|
||||
baseServ.WriteDebugOutput("Client Connected @ " + clientSock.RemoteEndPoint.ToString());
|
||||
ProcessRequests();
|
||||
clientSock.Close();
|
||||
|
||||
|
@ -107,7 +106,6 @@ namespace HTTP
|
|||
|
||||
private void RespondGet(string name)
|
||||
{
|
||||
baseServ.WriteDebugOutput("GET " + name);
|
||||
|
||||
if (ContentItemExists(name))
|
||||
{
|
||||
|
@ -156,7 +154,6 @@ namespace HTTP
|
|||
private void RespondHead(string path)
|
||||
{
|
||||
string name = Path.GetFileName(path);
|
||||
baseServ.WriteDebugOutput("HEAD " + path);
|
||||
|
||||
if (ContentItemExists(name))
|
||||
{
|
||||
|
@ -262,26 +259,37 @@ namespace HTTP
|
|||
{
|
||||
public List<ContentItem> Contents = new List<ContentItem>();
|
||||
public Socket ServerSocket;
|
||||
public void WriteDebugOutput(string txt)
|
||||
{
|
||||
Console.WriteLine("[HTTP] " + txt);
|
||||
}
|
||||
|
||||
|
||||
public void CreateClient(object sender, SocketAsyncEventArgs e)
|
||||
{
|
||||
do
|
||||
{
|
||||
if(shutdownServer)
|
||||
return;
|
||||
|
||||
Socket eSocket = e.AcceptSocket;
|
||||
if (eSocket != null)
|
||||
new ContentClient(this, eSocket);
|
||||
e.AcceptSocket = null;
|
||||
} while (!ServerSocket.AcceptAsync(e));
|
||||
}
|
||||
public ContentServer(string ip)
|
||||
|
||||
public void Shutdown() {
|
||||
shutdownServer = true;
|
||||
ServerSocket.Dispose();
|
||||
ServerSocket = null;
|
||||
}
|
||||
private bool shutdownServer = false;
|
||||
public string ipaddr;
|
||||
public short portnum;
|
||||
|
||||
public ContentServer(string ip, short port)
|
||||
{
|
||||
|
||||
WriteDebugOutput("Listening for connections on port 80.");
|
||||
IPEndPoint ep = new IPEndPoint(IPAddress.Parse(ip), 80);
|
||||
ipaddr = ip;
|
||||
portnum = port;
|
||||
|
||||
IPEndPoint ep = new IPEndPoint(IPAddress.Parse(ip), port);
|
||||
ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
ServerSocket.Bind(ep);
|
||||
ServerSocket.Listen(0x7fffffff);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue