Jump to content

HTTP Server


Recommended Posts

The page cannot be displayed

The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

The page cannot be displayed

The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.

<{POST_SNAPBACK}>

Same here
FootbaG
Link to comment
Share on other sites

Hmmm ok guys, thanks for the help. I might need to put myself as a DMZ server. This router is alittle harder to use then my netgear (A Linksys Router). Give me like twenty seconds and ill do that. Ill be at work today, so not much fixing is going to be able to be done:P

Crome

Link to comment
Share on other sites

LOLOLOL well Layer and i have started working on this server together.....i will share what ive managed to put together. We still have to read up on HTTP protocal and incorporate it into the program...but anyways:P

#include <GUIConstants.au3>

Opt("GUICloseOnEsc", 0)

Global $GUIWidth = @DesktopWidth / 2
Global $GUIHeight = @DesktopHeight / 2
Global $GlobalIP = @IPAddress1

Global $CSock = -1
Global $RSock = -1
Global $MSock = -1
Global $WhatIsGoingOn
Global $MainGUI
Global $File = FileRead(".\www\index.html", FileGetSize(".\www\index.html"))

$MainGUI = GUICreate("HTTP Server -- Not Listening " & $GlobalIP, $GUIWidth, $GUIHeight)

$WhatIsGoingOn = GUICtrlCreateEdit("", 5, 5, $GUIWidth - 10, $GUIHeight - 60, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY))

$FileMenu = GUICtrlCreateMenu("File")

$ExitMenu = GUICtrlCreateMenuitem("Exit", $FileMenu)

$Connect = GUICtrlCreateButton("Connect", 5, $GUIHeight - 45, 100, 20)
$Disconnect = GUICtrlCreateButton("Disconnect", 115, $GUIHeight - 45, 100, 20)
$ReloadIndex = GUICtrlCreateButton("Reload Index File", 245, $GUIHeight - 45, 100, 20)

GUICtrlSetState($Disconnect, $GUI_DISABLE)

GUISetState()

While 1
    
    $Msg = GUIGetMsg()
    
    Select
    Case $Msg = -3 Or $Msg = $ExitMenu
        Exit
        
    Case $Msg = $ReloadIndex
        $File = FileRead(".\www\index.html", FileGetSize(".\www\index.html"))
        
    Case $Msg = $Connect
        $Listen = _HTTPListen()
        $File = FileRead(".\www\index.html", FileGetSize(".\www\index.html"))
        If $Listen = 1 Then
            GUICtrlSetState($Connect, $GUI_DISABLE)
            GUICtrlSetState($Disconnect, $GUI_ENABLE)
        EndIf
        
    Case $Msg = $Disconnect
        _HTTPDisconnect()
        GUICtrlSetState($Connect, $GUI_ENABLE)
        GUICtrlSetState($Disconnect, $GUI_DISABLE)
        
    EndSelect
    
    _HTTPAcceptClients()
    
WEnd

Func _HTTPAcceptClients()
    
    If $CSock = -1 Then
        $CSock = TCPAccept($MSock)
        If $CSock >= 0 Then
            Return
        EndIf
    Else
        $Ret1 = TCPRecv($CSock, 500)
        If $Ret1 <> "" Then
            GUICtrlSetData($WhatIsGoingOn, "::" & $Ret1 & @CRLF, 1)
            $SplitI = StringSplit($File, @CR or @LF or @CRLF)
            If $SplitI[0] = 1 Then
                TCPSend($CSock, $SplitI[1] & @CRLF)
                GUICtrlSetData($WhatIsGoingOn, "Sent HTML File..." & @CRLF, 1)
            Else
                For $A = 1 To $SplitI[0]
                    TCPSend($CSock, $SplitI[$A] & @CRLF)
                Next
                GUICtrlSetData($WhatIsGoingOn, "Sent HTML File..." & @CRLF, 1)
            EndIf
            TCPCloseSocket($CSock)
        ElseIf @error Then
            TCPCloseSocket($CSock)
            $CSock = -1
        EndIf
    EndIf
    
EndFunc

Func _HTTPListen()
    
    $MSock = TCPListen($GlobalIP, 80)
    
    If $MSock = -1 Then
        Return 0
    Else
        WinSetTitle($MainGUI, "", "HTTP Server -- Listening " & $GlobalIP)
        Return 1
    EndIf
    
EndFunc

Func _HTTPDisconnect()
    
    WinSetTitle($MainGUI, "", "HTTP Server -- Not Listening " & $GlobalIP)
    
    GUICtrlSetData($WhatIsGoingOn, "")
    
    TCPCloseSocket($CSock)
    TCPCloseSocket($MSock)
    
EndFunc

Func OnAutoItStart()
    
    TCPStartup()
    
EndFunc

Func OnAutoItExit()
    
    _HTTPDisconnect()
    TCPShutDown()
    
EndFunc

I just tidyed up Layers code alittle, but you should just be able to (once u connect with the server) go to http://uripaddress and it will bring you right to your index.html (you have to create one:P)

Peace,

Crome

Edited by Crome_BAD
Link to comment
Share on other sites

  • 1 month later...

Quite nice but there is stuff missing:

-Ability for multiple clients

check link for hints in the source

-Correct http headers (check rfc2616 or use http header log)

-better buffering and waiting for data from client

-Ability to understand headers sent by client

-Ability to send files queried by get requests (so you can actualy send a complete website)

-something nice would be to add php wich is possible using the php dll file and making calls to it with dllcall

And I was trying this also but was looking for getting info on the connecting client,

I could not find wich ip adres was being accepted, is this missing or did I mis it?

Link to comment
Share on other sites

Yea, we sort of just like put a server together (with loads of help from blindwig and others) ... I'll admit, I don't know much about network programming, and I have really not a good knowledge on how to interact with the GET, POST, and other commands. So I just sort of put my learning on this on hault for a while, while I catch up on other stuff.

FootbaG
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...