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

Username:   Password: 
 RegisterRegister   
 Really need help on Local Area Network connections..
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
8749236




PostPosted: Wed May 25, 2011 6:47 pm   Post subject: Really need help on Local Area Network connections..

What is it you are trying to achieve?
I'm trying to make a program that can communicate with other computer on same LAN, but i can't did it even i'm using the example program in Turing 4.1...


What is the problem you are having?
The program i wrote won't connect to the IP i want, and i'm sure that computer have a same program is running..


Describe what you have tried to solve this problem
i tried to add my computer's IP to variable "netAddress", but it still not working..


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
This is the code from Turing, it is a example program in "Network.OpenConnection", i tried many times but i don't know why it can't link to another computer..

Turing:


        % The "Chat" program
        const chatPort : int := 5055
        var choice : int
        loop
            put "Enter 1 to run chat server"
            put "Enter 2 to run chat session"
            put "Choice: " ..
            get choice
            exit when choice = 1 or choice = 2
        end loop
        var netStream : int
        var netAddress : string
       
        if choice = 1 then
            netStream := Net.WaitForConnection (chatPort, netAddress)
        else
            put "Enter the address to connect to: " ..
            get netAddress
            netStream := Net.OpenConnection (netAddress, chatPort)
            if netStream <= 0 then
                put "Unable to connect to ", netAddress
                return
            end if
        end if
        Draw.Cls
        put "Connected to ", netAddress
       
        var localRow : int := 2
        var localCol : int := 1
        var remoteRow := maxrow div 2
        var remoteCol : int := 1
        var ch : char
       
        View.Set ("noecho")
        loop
            if hasch then
                ch := getchar
                put : netStream, ch
                if ch = '\n' then
                    localRow := localRow mod (maxrow div 2) + 1
                    localCol := 1
                    Text.Locate (localRow, localCol)
                    put "" % Clear to end of line
                    Text.Locate (localRow, localCol)
                else
                    Text.Locate (localRow, localCol)
                    put ch ..
                    localCol += 1
                end if
            end if
       
            if Net.CharAvailable (netStream) then
                get : netStream, ch
                if ch = '\n' then
                    remoteRow := remoteRow mod (maxrow div 2) +
                        1 + (maxrow div 2)
                    remoteCol := 1
                    Text.Locate (remoteRow, remoteCol)            put ""  % Clear to end of line
                    Text.Locate (remoteRow, remoteCol)
                else
                    Text.Locate (remoteRow, remoteCol)
                    put ch ..
                    remoteCol += 1
                end if
            end if
        end loop



Please specify what version of Turing you are using
Turing 4.1


What do i want
I want to know how to make it work properly(step by step) and how does it works(i think i already understand it but i want to make sure i'm correct)..
Sponsor
Sponsor
Sponsor
sponsor
chrisbrown




PostPosted: Wed May 25, 2011 8:21 pm   Post subject: Re: Really need help on Local Area Network connections..

Your connection code looks ok, so try pinging the server from the client machine.
If that fails, you have a network problem.

Otherwise, right before attempting to open the connection, add the line
Turing:
put "Attempting to connect to ", Net.HostNameFromAddress (netAddress)

This will output the name of the server computer if it is found. If it returns a blank name, you have a Turing connectivity issue. Check your firewall. If this is running at school, you may have to ask your sysadmin to open things up for you.


Finally, if that fails, change netAddress to 127.0.0.1, compile the program to a standalone executable, run it and put it in server mode. On that same machine, run the program the regular way (with the Run button) and attempt to connect. If that fails you have a problem in the code, and although nothing jumps out at me, I've been wrong many times before.
8749236




PostPosted: Wed May 25, 2011 8:53 pm   Post subject: RE:Really need help on Local Area Network connections..

thank you i'll try..
8749236




PostPosted: Thu May 26, 2011 8:45 am   Post subject: RE:Really need help on Local Area Network connections..

Made it, thank you, i think is because my school blocked the turing network connection, i will ask my school's InSchool Technician for help..
Thanks alot Smile
copthesaint




PostPosted: Thu May 26, 2011 9:08 am   Post subject: RE:Really need help on Local Area Network connections..

Make sure you tell him you just cnp'd your code, also look at tutorials, there is somethin there for net.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: