
-----------------------------------
Delta
Fri Mar 21, 2003 6:55 pm

[tutorial]Chat Program
-----------------------------------
This is all you need to create the base of any chat program in TURING

var stream : int := 0 % Used for sending data 
var msgBack : string % The message that gets sent back and forth 
var address : string % IP address for each computer 
var message : string  % Message that you send
var status : int % Status host/client

const PORT := 5555 % Port to connect through 

put "What would you like to do?" 
put "1:Host" 
put "2:Join" 

get status 

if status = 1 then 
    stream := Net.WaitForConnection (PORT, address) % Wait for a user to connect 
else 
    put "What is the IP of the computer you want to connect to?" 
    get address 
    stream := Net.OpenConnection (address, PORT) % Connect to the IP inputted
end if 
cls 
put "Connected to ", address 

loop 
    if hasch then % If key pressed
        get message : *  % store all input in var message when enter is pressed
        put : stream, message  % Send the message over the stream
    end if 
    if Net.LineAvailable (stream) then % If a line of text has been sent
        get : stream, msgBack : * % grab the line of text 
        put msgBack % print it to the screen
    end if 
end loop


MOD Edit: Woot, first user submited tutorial. Thx Delta +10 bits - Tony

-----------------------------------
Blade
Sat Mar 22, 2003 12:16 am


-----------------------------------
haha yeah! :D *eyeballs it* looks kinda familiar... haha maybe its cuz he wrote it for me to learn off of :D i'm so special! :D

-----------------------------------
Delta
Sat Mar 22, 2003 12:59 am


-----------------------------------
If anyone has any problems don't be shy ask me them through the forum and I might be able to help you or you can email me. :D 

THNX

-----------------------------------
leepham
Mon Mar 24, 2003 3:22 pm

...
-----------------------------------
Is there any reason why it doesn't work properly? The text is delayed, and it seems like it doesn't register some of the text sometimes.

Lee Pham

-----------------------------------
Tony
Mon Mar 24, 2003 4:36 pm


-----------------------------------
turing is not the best language to code networked data exchange for a bunch of reasons. Its slow and unreliable. The code here is fine, its the language itself (or perhaps the network :?)

turing also has a bug where sometimes it cuts off first few characters of the message send... so you might want to add a space or two at the beginning of the line just in case

-----------------------------------
Miyoko
Mon Mar 31, 2003 1:30 pm


-----------------------------------
I have a problem with it, some computers will wait for a client
stream := Net.WaitForConnection (PORT, address)
others will just bypass this line and foget the wait which makes to program crash when you get to
put "Connected to ", address

-----------------------------------
Delta
Mon Mar 31, 2003 2:03 pm


-----------------------------------
Yeah I had the same problem I couldn't find a way to get around it.

-----------------------------------
ferrara_999
Tue Sep 09, 2003 4:44 pm

address
-----------------------------------
what are the addesses for the various messenger services so it'll connect to em? (like msn messenger and icq)

-----------------------------------
Homer_simpson
Tue Sep 09, 2003 4:55 pm


-----------------------------------
bwahahahaha!!! i doubt that very highly...

-----------------------------------
octopi
Tue Sep 09, 2003 8:44 pm


-----------------------------------
msn is 1863, icq is 4000

You will need to impliment such things as a SSL connection...which I doubt turing can handle for msn, and icq will probally be trickier.

-----------------------------------
ferrara_999
Tue Sep 09, 2003 8:52 pm

nm
-----------------------------------
nm, lol, screw it then

-----------------------------------
Tony
Tue Sep 09, 2003 10:25 pm


-----------------------------------
I came across a custom MSN client writen in VB... with source code and all...

though it doesnt matter, cuz M$ patched their servers and users are forced to use MSN 5+

-----------------------------------
octopi
Tue Sep 09, 2003 11:04 pm


-----------------------------------
Your only required to use MSNP9 which is msn's latest protocol for the msn clients. 

Its not really that hard to do. Just not posible on turing, but in php, perl, c, c++, it is.
