#### Archived

This topic is now archived and is closed to further replies.

# webserver ( sort of )

This topic is 5489 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i want to be able to connect to my gameserver and check the status of it with a http browser ( im my case IE ) i have read a lot of info on the protocol and so on but just cant get it to work. I wont be posting any code here because its ugly and its FUBAR. So i wonderd if anyone could come up with a pice off code that lets IE connect to it and send this page back to IE
<HTML>
<BODY>
<p>Hallo World</p>
</body>
</html>

plz help me .. i just cant get this to work ( been trying for 3weeks now .. and it just wont work ! ) *my gameserver is working with socket.. so i know sockets ok : only this html protocol thing is killing me !* help plz !

##### Share on other sites
Why not let some already existing software do the job and only generate an html file?

By creating your own, you are inherently creating security issues so by using one that is already existant, you lessen your problems on the security and coding part.

ZixThree

##### Share on other sites
Is your gameserver on a ISS system? If so you could link browser to an .asp and let it talk to the gameserver process and spew HTML to the browser.

-solo (my site)

##### Share on other sites
The server in running on a comp in my friends house althu it is mine comp..

its not suposed to be a real webserver its just so i can type

http://181.243.15.18/ or whatever his ip is in IE

and connect and get a page back giving general info [NONE RISK INFO]
*incase i dint make the point clear: the gameserver is for a game i have made*

+ it is so i can learn this stuff ( i have tryed and failed a lot of times, now i want to see how it can be done ! )

[edited by - LogouT on July 3, 2003 6:05:49 PM]

##### Share on other sites
Many existing mud codebases have that built into them. Many of them are open source, so you can take a look there.

I know that you''re not trying to write a mud or anything, but that it is the same concept.

Michael Bartman
Dark Omen Studios
http://www.darkomenstudios.com/

##### Share on other sites
well i have but i ( me aint that good a programer )

dont understand all the code + they have wrapped it up in a load of class's and so on ..

why cant anybody just write the code that i ask for ?

it wouldnt take any time at all ...

but ofc since it looks like thats what i have to do..

[edited by - LogouT on July 3, 2003 6:35:20 PM]

*bump*

##### Share on other sites

Odds are you aren''t properly sending HTTP headers, usually web servers will give an internal error when you don''t send the HTTP header correctly. For you simple page:

Content-type: text/html\r\n\r\n

Int.

##### Share on other sites
Here''s what you need to do:

1) create a socket with "socket()" -- it needs to be an INET, STREAM, TCP socket.

2) bind the socket to port 80 on any local address using INADDR_ANY and port 80 (remember htons() !)

3) start listening with listen()

4) select() on the bound socket every so often to see if a connection is coming in

5) if a connection is coming in, call accept() which returns a new socket (the old socket is still listening)

6) read headers and request from this socket using recv(). Note that headers are a number of non-blank lines terminated by a blank line; then the request is a single line.

7) parse the request, and generate the data

8) write headers, followed by a blank line, followed by the response data, using send()

9) close the socket using closesocket() (WinSock) or close() (UNIX)

The headers you have to write in 8 include the status of the request (typically 200 Ok) and the headers "content-type: text/html", "content-length: %d", "cache-control: no-cache" and "connection: close".

For more information on WinSock/sockets, see your local man page or sockets programming tutorial. For more about the HTTP protocol, see the WWWC web page (www.w3c.org).

##### Share on other sites

You could also try the SDL_websrv library

http://jonatkins.org/SDL_websrv/

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 17
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631727
• Total Posts
3001914
×