Jump to content

Recommended Posts

Posted (edited)

Hello,

I'm trying to build a small webserver but i can't really get it to work. I tried alot of things, here's my code;

Can anyone help me out or give me a hint how to do this? I guess this wont work quite well with the HTTP protocol

Edit;

Also if i use HTTP strings like this;

local $sData = "HTTP/1.1 200 OK"  & @crlf & _
"Date: Tue, 29 Apr 2014 13:21:18 GMT" & @crlf & _
"Server: Bla" & @crlf & _
"X-Powered-By: Power" & @crlf & _
"Content-Length: 11" & @crlf & _
"Connection: close" & @crlf & _
"Content-Type: text/html; charset=utf-8" & @crlf 
 
It wont quite work :/
#include <MsgBoxConstants.au3>
 
TCPStartup()
 
Local $sIPAddress = @IPAddress1
Local $iPort = 80
 
Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
Local $iError = 0
 
Local $iSocket = 0
While 1
        $iSocket = TCPAccept($iListenSocket)
 
        ; If an error occurred display the error code and return False.
        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not accept the incoming connection, Error code: " & $iError)
        EndIf
if $iSocket <> -1 Then
consolewrite(TCPRecv($iSocket,100))
TCPSend($iSocket, "hello this is a webserver")
ExitLoop
EndIf
WEnd ;if different from -1 a client is connected.
 
 
 
TCPShutdown()
Edited by notsure
Posted

Hi,

I can tell you it works fine, your code is simply wrong.

I can't see anything here that can receive and send a proper response, please post your full code.

Br, FireFox.

Posted

Hi,

I can tell you it works fine, your code is simply wrong.

I can't see anything here that can receive and send a proper response, please post your full code.

Br, FireFox.

 

Hi FireFox,

This is my full code till now... is there any webserver UDF or something?

And what do you mean with : Its working fine?!

Nothing is working, except i can connect to Port80 TCP.

Thanks in advance,

Notsure.

Posted

This is my full code till now... is there any webserver UDF or something?

A lot of code is missing then.

There's a search engine ;)

And what do you mean with : Its working fine?!

I already made a limited webserver.

Br, FireFox.

Posted

A lot of code is missing then.

There's a search engine ;)

I already made a limited webserver.

Br, FireFox.

Hi Firefox,

I did use the search engine, but all hits ive seen are about winHTTP CLIENT-acting, not acting as server.

Could i have a look at your limited webserver, where can i find this?

Thanks alot man!

Gr,

Notsure.

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
  • Recently Browsing   0 members

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