Computer Science Canada

URL networks?

Author:  Taur [ Wed Dec 14, 2005 6:08 pm ]
Post subject:  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?

Author:  Paul [ Wed Dec 14, 2005 6:58 pm ]
Post subject: 

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 Net tutorial.

And remember to try using the search function available in the forum.

Author:  Taur [ Wed Dec 14, 2005 7:17 pm ]
Post subject: 

well I searched the help in turing for net and I found a URL thing so... Confused

Author:  Paul [ Wed Dec 14, 2005 7:25 pm ]
Post subject: 

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".

Author:  Taur [ Wed Dec 14, 2005 7:26 pm ]
Post subject: 

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?

Author:  codemage [ Thu Dec 15, 2005 1:35 pm ]
Post subject: 

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.

Author:  Taur [ Thu Dec 15, 2005 8:01 pm ]
Post subject: 

but it was done on that turing pac man wasn't it?

Author:  Albrecd [ Wed Dec 21, 2005 10:08 am ]
Post subject: 

Which turing pacman are you referring to?

Author:  md [ Wed Dec 21, 2005 3:22 pm ]
Post subject: 

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.

Author:  ecliptical [ Thu Dec 22, 2005 3:23 am ]
Post subject:  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...

Author:  [Gandalf] [ Thu Dec 22, 2005 4:04 pm ]
Post subject: 

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

Author:  ecliptical [ Thu Dec 22, 2005 4:39 pm ]
Post subject: 

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.

Author:  Taur [ Thu Dec 22, 2005 4:54 pm ]
Post subject: 

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?

Author:  [Gandalf] [ Thu Dec 22, 2005 4:59 pm ]
Post subject: 

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.

Author:  md [ Thu Dec 22, 2005 5:02 pm ]
Post subject: 

Taur wrote:
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?

Author:  Taur [ Thu Dec 22, 2005 5:09 pm ]
Post subject: 

Cornflake wrote:
Taur wrote:
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/

Author:  md [ Thu Dec 22, 2005 5:21 pm ]
Post subject: 

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.

Author:  Taur [ Thu Dec 22, 2005 6:17 pm ]
Post subject: 

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?

Author:  ecliptical [ Thu Dec 22, 2005 9:04 pm ]
Post subject: 

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.


code:


%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 <= 0 then
        put "Error could not send", score, "!"
        return
    end if

%Ok this is a little extra stuff that takes out all of the HTML from a file...I've notice turing is particular about access plain text files vs. HTML files (a HTML file with <HTML><HEAD>...</body>...etc works best.

    var flag : boolean := false
    loop
        exit when eof (netStream)
        get : netStream, net_line : 1
        if net_line = "<" then

            flag := true
        elsif net_line = ">" then

            flag := false

        end if
% So if it's not been flagged and isn't ">" or "<" then show us what's in the file.
        if not flag and net_line not= ">" and net_line not= "<" then
            put net_line ..
        end if
    end loop
%Just like with files onces you're done using it put it away.
    Net.CloseConnection (netStream)


end sendScoreTOServer

loop
    var playerscore,playerid : string
put "What is you name?"
get playerid
put "What was your score
    get playerscore
   % now lets use our fancy procedure to send the score
    sendScoreTOServer (playerscore, playerid)

end loop


Thats the client (Turing) side of it now lets look at what we'll do on the server side .

On the server side using your language of choice (php, asp, cgi..etc)
you'll write the values that are passed in the url to a file or put them inside database query.

Like I said full tutorial coming soon...just making a little game to go with it.
You can also use this method to make a turn based game which I will also write a tutorial on.

Author:  Taur [ Sat Dec 24, 2005 1:29 pm ]
Post subject: 

Very Happy thx plz do post a full tut


: