Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Looking for Turing Command to send variables to server via internet
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
deltamanx




PostPosted: Wed Jan 06, 2010 12:17 am   Post subject: Looking for Turing Command to send variables to server via internet

Hello there,
I'm attempting to make a code that would get the user's username and password (which I succeded at), and then send those creditentials over to a server
where they could be compared with a list of account, if it exist and the username/password entered was correct to log the person into the program.
The problem I'm facing is making the actual code to send the variables (username/password) over to the server, and then for the server to send a reply.
If this helps; I am using turing version 4.1.1, and understand the fact that I will need to put the two parts (server and client) into two different programs.
If any one could assist me, I'd be very grateful.
deltamanx.
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Wed Jan 06, 2010 2:00 am   Post subject: RE:Looking for Turing Command to send variables to server via internet

Look at the example code Turing Help on the Net module. Be forewarned: Turing is horrendously bad at networking.
mirhagk




PostPosted: Wed Jan 06, 2010 7:20 am   Post subject: RE:Looking for Turing Command to send variables to server via internet

you can only send data over a local network, and you need the ip of the server, which may be difficult at school where the server could not stay running all the time.

Personally I'd suggest just using an encrypted file and decrypt the user names and passwords to compare it. As long as you encrypt it pretty good, most people would be unable to *hack* it.
deltamanx




PostPosted: Wed Jan 06, 2010 2:22 pm   Post subject: Re: Looking for Turing Command to send variables to server via internet

For those who didn't completely understand:
I'm hosting the server with a turing application.
I need to make a turing application that will connect to said server.
Here's a bit of server code:
code:

var userName, passWord : string := "null"
const ClientPort : int := 5055
const ClientIP : string := "127.0.0.1"
~~~
~~~
~~~
    put "Checking connection (This may take a while.) = " ..
    delay (500)
    net := Net.OpenConnection (RSClientIP, RSClientPort)
    if net <= 0 then
        put "ERROR!"
        delay (1000)
        return
    else
        put "OK!"
    end if
~~~
~~~
~~~
    if userName = "null" and passWord = "null" then
        put "User Name: " ..
        get userName : *
        put  net," ", userName
        put ""
        put "Password: " ..
        get passWord : *
        put  net," ", passWord
    else
        put "You have already entered a username and password ", userName
        put ""
    end if


And my server code:
code:

var net : int
var userNameok, passWordok : boolean := false
var ip : string
const port : int := 5505
var userName, passWord : string

~~~
~~~
~~~

net := Net.WaitForConnection (port, ip)

get net, userName
get net, passWord

put "UserName: ", userName
put "PassWord: ", passWord

~~~
~~~
~~~

if userNameok true and passWordok true then
    resend := 1
    put net, resend
else
    resend := 0
    put net, resend
end if
DemonWasp




PostPosted: Wed Jan 06, 2010 2:37 pm   Post subject: RE:Looking for Turing Command to send variables to server via internet

You use put to write things over network streams. This looks almost exactly like writing data to a file:

code:

put : streamID, stuff-to-put


Similarly, you can use get to read from the network. This looks like:

code:

get : streamID, variable-to-fill


You appear to be missing some colons.
DtY




PostPosted: Wed Jan 06, 2010 5:19 pm   Post subject: Re: RE:Looking for Turing Command to send variables to server via internet

mirhagk @ Wed Jan 06, 2010 7:20 am wrote:
you can only send data over a local network.
Sending data to a remote server (ie. not on the local network) can be done exactly as it would a machine on the local network. The only difference is the IP address wouldn't be in the subnet mask (if that's the right word?).
deltamanx




PostPosted: Wed Jan 06, 2010 6:01 pm   Post subject: Re: RE:Looking for Turing Command to send variables to server via internet

Yes I noticed after posting that I was using:
Code:
get net, userName
put net, userName

In stead of:
Code:
get : net, userName
put : net, userName

What worries me is the mention of;

DtY @ Wed Jan 06, 2010 5:19 pm wrote:
mirhagk @ Wed Jan 06, 2010 7:20 am wrote:
you can only send data over a local network.
Sending data to a remote server (ie. not on the local network) can be done exactly as it would a machine on the local network. The only difference is the IP address wouldn't be in the subnet mask (if that's the right word?).


Could I simply substitute a server on a different programming language (Visual Basic, Java) or would I have to redo client as well?
DemonWasp




PostPosted: Wed Jan 06, 2010 7:15 pm   Post subject: RE:Looking for Turing Command to send variables to server via internet

You could (theoretically; Turing may not behave perfectly and I'm too lazy to test) swap out another language for either server or client, as long as the network "language" - what you send back and forth - remains the same. One interesting thing to note is that networks may use a different endianness than the platform you're on, so you may have to correct for that.
Sponsor
Sponsor
Sponsor
sponsor
deltamanx




PostPosted: Wed Jan 06, 2010 8:24 pm   Post subject: RE:Looking for Turing Command to send variables to server via internet

Succes!

I redid the code for the server in Visual Basic;
I didn't expect it to have any affect, however,
one of my friends managed to connect to the server from the client (still programmed it Turing) to the server, with little trouble.

Thank you any way.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: