Skip to main content
GameDev.net gamedev.net
🔒 Locked

online hiscores --mysql database

Started by Penguins Dec 30, 2003 at 1:27 AM 16 replies 2.5k views
Original Post
Penguins
Penguins
im trying to add online hiscores to tetris clone ive made .. where can i find articles on how to directly connect to an mysql database or indirectly send data to a perl or php script (i can handle it once i have the data sent to the script) from a program written in c. google has proved unhelpful so far .. perhaps i dont know what im searching for .. any help?
smart_idiot
smart_idiot
Say you wanted to post something to www.somewhere.com/asdf.pl
Open a TCP/IP stream to the server, probably on port 80, and send:


POST /somescript.pl HTTP/1.1
Host: www.somewhere.com
User-Agent: <probably the name of your program here>
Content-length: <how many bytes of data we''re sending>
<-- blank line.
<-- blank line.
<the data you wanted to send>


The server should return:

HTTP/1.1 <number> <some text>
<stuff you can ignore>


If that number is in the range of 200-299, then all is well. 400-499 would indicate and error.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
smart_idiot
smart_idiot
Oh, you should also probably tell the server what you''re sending.

Content-type: application/x-www-form-urlencoded


is a likely choice.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
Penguins
Penguins
thanks



... *goes to research tcp/ip streams
Ruudje
Ruudje
though the above sounds much more interesting, maybe take a look at mysql++ ?
_buu_
_buu_
quote:
Original post by smart_idiot
Say you wanted to post something to www.somewhere.com/asdf.pl
Open a TCP/IP stream to the server, probably on port 80, and send:


POST /somescript.pl HTTP/1.1
Host: www.somewhere.com
User-Agent: <probably the name of your program here>
Content-length: <how many bytes of data we''re sending>
<-- blank line.
<-- blank line.
<the data you wanted to send>


The server should return:

HTTP/1.1 <number> <some text>
<stuff you can ignore>


If that number is in the range of 200-299, then all is well. 400-499 would indicate and error.



99% correct, you just had one too many new lines (Not that it probably matters, but still..). HTTP Spec specifies TWO \n as the header-section terminator, but each header is terminated by a \n, so you only need one additional new line after the one that terminates the last header.

Content-type: text/html\n\n
Penguins
Penguins
quote:
Original post by Ruudje
though the above sounds much more interesting, maybe take a look at mysql++ ?


that looks good .. although id rather send the scores to a script and use mysql++ for reading the scores.

thanx for the replies
Penguins
Penguins
im slightly confused, what do you mean when you say open a tcp/ip stream , open a socket on port 80?
smart_idiot
smart_idiot
Beej''s Guide to Network Programming

Simple Stream Client

Note for Windows Programmers
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
Penguins
Penguins
<> strangely i was just reading that, in combination with game tutorials networking examples. thanks
GroZZleR
GroZZleR
Could you not cheat by sending faulty information to this script? How would you make sure the score is legitimate?

I''m curious because I''m interested in something similar myself.
Penguins
Penguins
well how would ~they~ know what/where the script is, and if they do know somehow you could just encrpyt -send- and decrypt in the script, although that would be slower and the article above mentions using ssl to encrypt/compress stuff, although i have very little idea what that it
GroZZleR
GroZZleR
Monitoring Internet Connections?

Reverse Engineering?

I imagine it''d probably be pretty easy to find out what the program is telling itself to find the script.
smart_idiot
smart_idiot
It's always possible to cheat. You can never trust anything from a clients computer. Your best way would be save the seed used to start the game along with what moves you made so the server can verify that everything you did was possible and added up to the correct score. Of course that still wouldn't stop cheating because there's no reason someone couldn't just write a program to play for them.

[edited by - smart_idiot on January 2, 2004 1:56:33 AM]
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
emileej
emileej
Penguis << I reccomend Beejs guide - all you need
smart_idiot << EEK! I have been lookin for the http request header for some time now! Copy/pased ;P
Emil Johansen- SMMOG AI designerhttp://smmog.com
smart_idiot
smart_idiot
This might interest you.

As _buu_ pointed out I made a mistake. I was thinking two newlines made two blank lines, but it only makes one.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
Penguins
Penguins
change the outcome (besides making max_message_size smaller which makes the less characters come out in the end




501 Method Not Implemented

Method Not Implemented


to / not supported.


Invalid method in request


</body></html>
¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨d¨„


any ideas on what is causing this madness?

[edited by - penguins on February 8, 2004 5:59:54 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.