
-----------------------------------
Taur
Wed Dec 14, 2005 6:08 pm

URL networks?
-----------------------------------
I honestly don't get how to establish a netstream with a URL, can someone give me an example s

and I don't udnerstand the concept, I mean I understand that you can read information from a website, but send info? How does the website owner use it, does it require some coding on the website's behalf? 

Can websites me used as um.. links between computers not connected to each other? E.g. send info to website which sends it to the other comp?

-----------------------------------
Paul
Wed Dec 14, 2005 6:58 pm


-----------------------------------
It seems that you're talking about a server-client interaction. I don't know about that in turing. Though you may want to look at danshadow's [url=http://www.compsci.ca/v2/viewtopic.php?t=5795]Net tutorial. 

And remember to try using the search function available in the forum.

-----------------------------------
Taur
Wed Dec 14, 2005 7:17 pm


-----------------------------------
well I searched the help in turing for net and I found a URL thing so...  :?

-----------------------------------
Paul
Wed Dec 14, 2005 7:25 pm


-----------------------------------
Well would you be more specific as to what you're looking for?
I've seen programs like checkers be done over a network by either sending packets in between the two computers, or by going through a server. I have never heard of this "URL thing".

-----------------------------------
Taur
Wed Dec 14, 2005 7:26 pm


-----------------------------------
okay different example

how do some programs use high scores? Obviously to compare all high scores they have to a) submit thier socres b) read the other scores of other players from somewhere, like in pacman

how would I do this?

-----------------------------------
codemage
Thu Dec 15, 2005 1:35 pm


-----------------------------------
Coding is done on both sides.

The program sends data in a form that the site will recognize.

The site usually stores data in a database (for highscores, etc).

Then an interactive language like PHP or ASP displays data on the website and/or makes the data available so the user's client-side program can get it from online.

I'm not sure how well Turing would be able to pull something like that off.

-----------------------------------
Taur
Thu Dec 15, 2005 8:01 pm


-----------------------------------
but it was done on that turing pac man wasn't it?

-----------------------------------
Albrecd
Wed Dec 21, 2005 10:08 am


-----------------------------------
Which turing pacman are you referring to?

-----------------------------------
md
Wed Dec 21, 2005 3:22 pm


-----------------------------------
If it's high scores local to a single machine you don't need network code at all. If it's global do the following

1. connect to server
2. send high score and user name
3. server generates new high scores list
4. server returns user's position in the list
5. server returns top x scores
6. client displays stuff

Simple! How you do that using the turing net code is beyond me; but the idea behind it is rather easy if you think about it.

-----------------------------------
ecliptical
Thu Dec 22, 2005 3:23 am

I finsihed this!
-----------------------------------
I just finished writing a Turing Highscore Program I'm going to provide the source as well as a tutorial on how it works...

-----------------------------------
[Gandalf]
Thu Dec 22, 2005 4:04 pm


-----------------------------------
Does it do something like what Cornflake described?  If not, we already have these:
http://www.compsci.ca/v2/viewtopic.php?t=7499
http://www.compsci.ca/v2/viewtopic.php?t=5340

-----------------------------------
ecliptical
Thu Dec 22, 2005 4:39 pm


-----------------------------------
No mine uploads your score to a webserver. So you can share/compare your accomplishments. No browsers required everything is handled and rendered within a turing window.

-----------------------------------
Taur
Thu Dec 22, 2005 4:54 pm


-----------------------------------
I'm sorta confused, I see the file streams in both of those, but I don't see where it is opened. Like  how does it connect? I mean, with other file streams you specifi the URL or the machine address but with these ones?

-----------------------------------
[Gandalf]
Thu Dec 22, 2005 4:59 pm


-----------------------------------
Mmm?  The two I posted?

They do not connect to a server, they simply read/write to the file which is on your computer, in the same directory as the .exe or .t.

This is a good example of why starting out more complex and going simpler is bad when it does happen.

-----------------------------------
md
Thu Dec 22, 2005 5:02 pm


-----------------------------------
I'm sorta confused, I see the file streams in both of those, but I don't see where it is opened. Like  how does it connect? I mean, with other file streams you specifi the URL or the machine address but with these ones?

The examples given are actually for text files, not network interaction. If you want to get files from a webserver you need to connect using a socket (or turing equivalent) and use HTTP queries/comands to talk to the server; sending information requires the same type of thing. Just to clarify network != files. Perhaps someone can write a turing networking tutorial and post it on the wiki?

-----------------------------------
Taur
Thu Dec 22, 2005 5:09 pm


-----------------------------------
I'm sorta confused, I see the file streams in both of those, but I don't see where it is opened. Like  how does it connect? I mean, with other file streams you specifi the URL or the machine address but with these ones?

The examples given are actually for text files, not network interaction. If you want to get files from a webserver you need to connect using a socket (or turing equivalent) and use HTTP queries/comands to talk to the server; sending information requires the same type of thing. Just to clarify network != files. Perhaps someone can write a turing networking tutorial and post it on the wiki?so its possible/

-----------------------------------
md
Thu Dec 22, 2005 5:21 pm


-----------------------------------
It is possible to get files from a webserver, posting data requires some scripting on the server side as well, but it can be done. How you'd go about doing it in turing I don't know; but assuming you can open a connection the HTTP protocol isn't that dificult to master.

-----------------------------------
Taur
Thu Dec 22, 2005 6:17 pm


-----------------------------------
well yes you can, open a URL network and read the source from it (sometimes), but I dno't know how to manipulate that

don't servers also have addresses? like IP's? can't we use that and connect to them like we do comps?

-----------------------------------
ecliptical
Thu Dec 22, 2005 9:04 pm


-----------------------------------
Taur,

I'll write a complete tutorial in the near future but here's a basic (an working) version of what you're looking for. 




%First we create a procedure to define all the important stuff.

procedure sendPlayerScore (player:string, score : string)

%netStream is the location(file) we'll be accessing.
    var netStream : int
% net_line is each character we will be downloading from the file
    var net_line : string (1)

%This is where you define the url of the location that will be handling the script.

netStream := Net.OpenURLConnection ("http://72.29.76.231/~eclipti/turing/turingtag.php?player=" + player + "&move=" + move)
%In this case the address is of particular importance because we are POSTING values within the url that php file can use.

%Before we do anything lets make sure we actually have a connection 
    if netStream 