Jump to content

TCP HTML Server


Recommended Posts

Hi, it's me again... Umm... I've started reading this manual thing for HTTP... And I've read some on the GET command, but it doesn't tell me how to respond to it, the only way I got the page to say "test" was to exit out of the server and then the page would finish loading. I think that's because I didn't respond to the commands, but I have no idea how, because I can't find any 'instruction' type things... Like when I get this from me trying to go to 127.0.0.1:

Do I actually have to type something back? Once I know what to respond back I can automate it pretty easily... I just need a kick in the butt I guess.

Thanks, again... :)

<{POST_SNAPBACK}>

Did you do what I told you to do? Do you have individual commands going into the parser?

Now that you have commands coming into the parser, you need to parse them. I don't know HTTP offhand, but it looks like a command and it's parameters are seperated by spaces, so you might want to use StringSplit to parse them.

Again, I'm going off assumptions here, check the HTTP RFC for details, but it appears that:

A command is a string up until the first space. The command could be a command (like GET or POST) or a setting if it ends with a colon (like 'Accept:' or 'Host:')

Finally, just read the RFC to see what you're supposed to do with the commands and settings.

Oh, and about the browser not seeing the page until you close your script - this is normal. A browser doesn't render a page until it receives the EOF marker, but since there is no hard EOF, the only way to end the file is to close the connection. So when a browser sends you a GET command, you return the page it requests and then immediately close the connection. This information should be part of the HTTP spec, and I'm sure it's in the RFC.

To see what a real web server does (so that you can experiment with various commands) telnet into a known web server (port 80) and type the commands (or paste them from notepad, otherwise the connection might time-out on your slow typing) (or just write a script to connect and send a string of text and display the responce).

Try this:

TELNET WWW.AUTOITSCRIPT.COM 80

GET /

you should see the HTML code, and then a notice that the connection has been terminated.

I don't know much about HTTP, and I've never built a server from scratch, so there's not much more I can help you beyond this...

Good Luck!

Link to comment
Share on other sites

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

EDIT: Oh yea, one more thing... Are the TCP commands only supposed to work on a network or something? Because I ran my server script up above and was online with my cousin. I told him to run telnet [MYIP] 80 and he did, and it didn't connect to my server... So am I able to use these TCP commands on my computer and be able to actually chat with my cousin at his house?

<{POST_SNAPBACK}>

#1 - do you have a public IP? What's you computer's IP address? Your computer might be behind a NAT (very common, for security reasons), or your entire internet connection might be behind a NAT (very common on wireless providers)

#2 - does your ISP block port 80? Most residential-grade ISPs block certain ports because they don't want you running a server (either for bandwidth reasons or for security or support reasons). Try listening on a different port (above 1024) and see if it works.

Link to comment
Share on other sites

Yes, I have a public Ip, but I don't like giving it out on a forum :) I tried listening on my public Ip and when I start the script, it closes right away... Is that normal? NAT? Is that Norton? Because I do have Norton installed... I think my ISP is fine though, but what is NAT?

Again, I thank you very much for your time and patience! :evil:

FootbaG
Link to comment
Share on other sites

network address translation?

<{POST_SNAPBACK}>

What's it do then? How do I get around it so I can actually have a connection with my cousin? :evil:

Grr... Don't know how to thank you guys :)

FootbaG
Link to comment
Share on other sites

Does anybody else see the irony in someone trying to write an HTTP server, yet they know absolutely nothing about networking in general; so much so that they can't even get the outside world to see them?

Link to comment
Share on other sites

Well, in that case, I thought I might know the answer to work around NAT... Port forwarding... But that was just from my experience with setting up game servers. Maybe I don't know much about programming -- but that's because I can get "outside" of the computer and have a life. The thing is, the site I went to portforward a while ago didn't support my router. It had the product company (Belkin) but not my type... I'm sleeping over my cousins tonight, so if port forwarding is the case, it's gonna have to wait till' I get home...

Thanks

FootbaG
Link to comment
Share on other sites

Haha awesome! I got a site up... The only thing I'm not happy with is that the name of the site is my Ip... And I don't think it's too safe to give out my Ip... And the whole purpose of this project was to have a free site... That I could share, but I can't share it because the site name is my Ip! And the only what to get an actuall domain name is to pay, correct?

Thanks for all the help and recommndations, I think I've acomplished my goal here...

EDIT: Oh yea, currently I'm using freewebs to host my pictures... Because I'm still learning, but I got the very basics of the basics down. :)

Edited by layer
FootbaG
Link to comment
Share on other sites

http://layerstest.cjb.net

That's only a test... When I get home I'll make a permenant one and post it here... But I still have that NAT problem at home :evil: So it may not work, but we'll see, I'm sure theres a way to fix it. I'm going to try that Dot TK site too! Thanks for all of these tips guys! :)

FootbaG
Link to comment
Share on other sites

  • Developers

http://layerstest.cjb.net

That's only a test... When I get home I'll make a permenant one and post it here... But I still have that NAT problem at home :D So it may not work, but we'll see, I'm sure theres a way to fix it. I'm going to try that Dot TK site too! Thanks for all of these tips guys! :evil:

<{POST_SNAPBACK}>

check the manual for your NAT router how to set the DMZ host of redirect port 80 to your PC.... simple :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Sorry guys, had to close the server down for now... Once I learn a little bit more about security, I'll get a permanent server up... And thanks JdeB! I'll try that when I get home!

FootbaG
Link to comment
Share on other sites

how did u host a file into .tk? isnt .tk only url forwarding or masking url? -.- how come u can host on it -.-

My .tk is a paid domain, but a free .tk is still a free top-level domain! :)
Link to comment
Share on other sites

Just wanted to point out, even if you have a domain that points to your IP, doesn't mean that your IP is hidden. Anybody you want accessing the site can access your IP. That's just the way it is. The only way to not reveal your IP is to not use your computer as a server.

You might not see my IP in my domain (rksa.no-ip.com) but if you ping the domain, it will be there. Try it yourself.

Link to comment
Share on other sites

Sanders, Larry had warned me about this already... Thanks though :) Currently, I'm looking for a cheap computer in my neighborhood to use as a server. I'll firewall it up, and have no networking transaction, besides the server, also suggested by Larry! :D But I can't order a cheap computer online because I don't think my parents would like it... In fact I doubt they'll like the extra computer -- but I guess I'm a pretty good negotiator :evil:

FootbaG
Link to comment
Share on other sites

  • 1 month later...

Who says its not possible with autoit, I am working on this.

Nothing is impossible:)

But I cannot find how to get the ip address from the connecting client wich could be nice for the log file (ofcourse sometimes the client send its ip address in the header but thats the internal ip and it can be avoided (for attacks its nice if its the real ip address.

maybe it must be done using direct dll calls:s

Hmm what do you send back after getting a get request try using http headers how do you get them not difficult use telnet to connect to a http server and send a complete get request including the other headers and you wil get the html file but first you get the headers (wich have several possibilities)

I made a simple server wich send

HTTP/1.1 200 OK

Server: Bug report 001

Content-Type: text/html

Expires: Mon, 26 Jul 1997 05:00:00 GMT

This works but donot forget to have a blank like after the headers

examp:

Expires: Mon, 26 Jul 1997 05:00:00 GMT @CRLF

@CRLF

donot forget the blank line

to read the get request use stringsplit to split betweN crlf

and for the other headers you can split between : (first part is header title second part is header data)

Edited by MrSpacely
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...