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

Username:   Password: 
 RegisterRegister   
 Networking... What if i don't have two pcs?
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Decadence666




PostPosted: Sun Jun 24, 2007 9:54 pm   Post subject: Networking... What if i don't have two pcs?

Is there some kind of setting, or hack that would allow me to run two instances of turing at the same time?

Kind of hard to test networking stuff with only one computer...

Thanks for any suggestions.


[EDIT] I tryed compiling the program, and then running one instance of the example "chat" program, and then the other instance with the EXE.... That just realled fucked things up.... Don't try it Wink...
Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: Sun Jun 24, 2007 10:04 pm   Post subject: RE:Networking... What if i don\'t have two pcs?

I may be wrong but its impossible if you are running it from the compiler. But you can compile the exe and then run start the program twice that way you have two instances running. Thats the only way you can do it.
Decadence666




PostPosted: Sun Jun 24, 2007 10:07 pm   Post subject: RE:Networking... What if i don\'t have two pcs?

Nope... Didn't work....


Same thing happened as when i ran it from the turing editor...

Heres a screenie, i'm not gonna embed it in the page cuz my resolution is 1440x900, it will stretch the page...

http://i17.tinypic.com/5253z8j.gif <--- result

Maybe this is just the program's fault???
Saad




PostPosted: Sun Jun 24, 2007 10:09 pm   Post subject: Re: Networking... What if i don't have two pcs?

127.0.0.1 is your internal ip. You cannot network with this. Use you real ip

To find your ip goto http://whatsmyip.org/
Decadence666




PostPosted: Sun Jun 24, 2007 10:11 pm   Post subject: RE:Networking... What if i don\'t have two pcs?

Well... If I'm running two instances on the same computer, wouldn't localhost make sense?

My real ip didn't work. It said "could not connect".
Decadence666




PostPosted: Sun Jun 24, 2007 10:15 pm   Post subject: RE:Networking... What if i don\'t have two pcs?

Do you have msn, it would make things alot faster. If you do add me up, brightwing[at]gmail[dot]com
LaZ3R




PostPosted: Sun Jun 24, 2007 10:32 pm   Post subject: RE:Networking... What if i don\'t have two pcs?

firewall off? port blocking?

Works fine when I test net programs on my own computer. I compile and run the compiled version along with the uncompiled version since it makes no diff when testing.
Decadence666




PostPosted: Mon Jun 25, 2007 5:15 am   Post subject: RE:Networking... What if i don\'t have two pcs?

Laz3r, are you using your external ip, localhost, or what?
Sponsor
Sponsor
Sponsor
sponsor
Decadence666




PostPosted: Mon Jun 25, 2007 5:34 am   Post subject: RE:Networking... What if i don\'t have two pcs?

Ok, I even tryed it with a temporary second pc, on the network, i used the network address (192.169.0.100) and it sitll gave me the same crap... Maybe its the turing program itself?
Decadence666




PostPosted: Mon Jun 25, 2007 5:43 am   Post subject: RE:Networking... What if i don\'t have two pcs?

I think that its the program thats going wrong... Because it connects fine... but then the way it outputs is totaly messed up. It sends data on every key press... Maybe its the program?
Decadence666




PostPosted: Mon Jun 25, 2007 6:04 am   Post subject: RE:Networking... What if i don\'t have two pcs?

Ok. I think I got it working..... I think it was just the turing example chat program sucking ass that was the problem...

it even works fine on localhost!

PROGRAM1
code:
% The "Chat" program
const chatPort : int := 5055
var choice : int
loop
    put "Enter 1999 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 : string (100)

loop
    if Net.LineAvailable (netStream) then
        var line : string
        get : netStream, line : *
        put line
    end if
end loop



PROGRAM 2
code:
% The "Chat" program
const chatPort : int := 5055
var choice : int
loop
    put "Enter 1999 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 : string (100)

loop
        get ch :*
        put: netStream, ch
 
end loop


ch is a string, i was just to llazy to change the variable name[/syntax]





[EDIT] WOW.... sorry for the 4 posts in a row.... it was 5 in the morning....
Tony




PostPosted: Mon Jun 25, 2007 8:48 am   Post subject: RE:Networking... What if i don\'t have two pcs?

Actually that's what you were supposed to do - compile one or both of the programs, and run them through localhost. Don't forget to use different ports though.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Decadence666




PostPosted: Mon Jun 25, 2007 12:32 pm   Post subject: RE:Networking... What if i don\'t have two pcs?

Wait, different ports.. so they aren't receiving the same message? Well, i'm starting a game where one player is the server, and the other is the client, so ports might not matter? well. ill see about that.
Tony




PostPosted: Mon Jun 25, 2007 12:55 pm   Post subject: RE:Networking... What if i don\'t have two pcs?

If you are running both instances on the same computer, and they are both communicating through the same port - you will have problems.

The example "works" because the server only reads and client only writes, so there is no interference.

Think of a port like a dedicated communication channel between two instances. If I recall my multichat app from back in the day, the server would use as many ports as there were participants in the chatroom.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Decadence666




PostPosted: Mon Jun 25, 2007 12:56 pm   Post subject: RE:Networking... What if i don\'t have two pcs?

Cool cool, they could be on the same port as long as they had different ip's right?
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 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: