Computer Science Canada net chat |
Author: | white_dragon [ Mon May 09, 2005 12:42 pm ] |
Post subject: | net chat |
found this searchin the net pretty cool [code] % The "NetChat" program const chatPort : int := 5055 var choice : int var keys : array char of boolean var keysp2 : array char of boolean var x, y, x2, y2 := maxx div 2 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 View.Update put "This machine is '", Net.LocalName, "' at net addresss ", Net.LocalAddress put "Waiting for a connection... " netStream := Net.WaitForConnection (chatPort, netAddress) View.Update 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 Text.Cls setscreen ("graphics; offscreenonly") loop cls Input.KeyDown (keys) if keys (KEY_UP_ARROW) then y += 1 end if drawoval (x, y, 5, 5, red) View.Update exit when Error.Last not= 0 end loop var error := Error.Last var msg := Error.LastMsg Text.Locate (maxrow - 1, 1) put repeat ("=", maxcol - 1) if error = 0 then Net.CloseConnection (netStream) put "Chat terminated by you" .. else put "Chat aborted - Error #", error, ": ", msg .. end if [/code] |
Author: | Andy [ Mon May 09, 2005 7:42 pm ] |
Post subject: | |
1. chat programs have been posted on compsci many many times 2. its even built in turing help menu |