"KiXforms TCP connection Example script by Jooel 14th of December 2005" ?
"Server Side." ?
? "Once this script is in the waiting state, start the client sample."?
$s = CreateObject("kixforms.system")
 $ = SetOption("wrapateol","on")

"Getting the IpAddress object For localhost" ?
"	resolving: " $entry = $s.dns.resolve("localhost") "	" @serror ?
"	retrieve addies: " $list = $entry.addresslist "	" @serror ?
"	addresses: " $list.count "	" @serror ?
"	ipaddy0 is: " $list.item(0) "	" @serror ?

? "Then to the real deal." ? " Creating the Listener: "
 $Server = $s.tcpListener($list.item(0),2332)
 @serror ?

" and then starting it: "
 $Server.start()
 @serror ?

? "going to a loop that waits for clients."
? "	So, now it's the time to execute the client sample." ?
? "you can end this script by hitting some key"
Do Sleep 1 Until KBHit() Or $Server.Pending()

If Not $Server.Pending()
	? "you wished this to end, so be it."
	 Sleep 2
	 Quit
EndIf

? "Accepting the connection: "
 $client = $Server.AcceptTCPclient()
 @serror ?

"and then stopping the listener so no new connections will get in the queye: "
; a real server probably wouldn't do this, but this is just a example, right?
 $Server.Stop()
 @Serror ?

"We need to open the Stream to be able to read or write from/to it: "
 $NetStream = $client.getStream()
 @serror ?

? "so... Let's start waiting for some input from client..."
? "Again, you can quit the script if you wish so."
Do
	Sleep 1
	If KBHit()
	 ? "getting tired? fine. quitting..."
		$NetStream.Close()
		$client.Close()
		Sleep 2.5
		Quit
	EndIf
Until $NetStream.DataAvailable

If Not $NetStream.CanRead
	"for some reason, the stream is not readable." ? " can't proceed, thus quitting..."
	Quit
EndIf

? "Ok, there is some data available in the stream."
? "Displaying the data, 80 characters per line:" ?
While $NetStream.DataAvailable
 ?
 $dataRead = $NetStream.Read(0,20)
 For $=0 to Ubound($dataRead)
 	Chr($dataRead[$])
 Next
Loop

? "and here ends our example." ?
"Press a key to quit."
Get $