;region Script Settings ;WKIX32.EXE ; ;%TEMP% ;C:\Documents and Settings\dale\Desktop\send kixtar exe over stream ; ;True ; ;True ; ;False ;True ;True ;False ; ; ;True ; ; ;1.0.0.1 ; ; ; ; ; ; ; ;endregion "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." ? "Saving it to file." ? $counting = 0 $FileOut = $s.FileStream(@scriptdir+"\jooels_kix.exe",$s.filemode_create) While $NetStream.DataAvailable ? $dataRead = $NetStream.Read(0,1024) $counting = $counting + Ubound($dataRead) + 1 "Bytes Read: " $counting ? $FileOut.write($dataRead,0,Ubound($dataRead) + 1) Loop $FileOut.Close() ? "and here ends our example." ? "Press a key to quit." Get $