#!/usr/bin/wish # The previous line defines the script interpreter that is going to be used global line #===================================================================== proc Reader {stream} { #This procedure is called when ever some information is #available from the VME sgarface controler. It Reads the #information and process it depending on the naure of the #information #------------------------------------------------------ #Reads a line #gets $stream line global response set response [read $stream] return } #===================================================================== # MAIN WINDOW #--------------------------------------------------------------------- #Sets the title of the main window wm title . "TCP/IP Client" entry .entry -width 20 -textvariable msg pack .entry button .send -text Send -command { puts $io $msg set msg "" } pack .send global response entry .resp -width 20 -state disable -textvariable response pack .resp button .quit -text Quit -command { exit } pack .quit #Use the following if client and server running on the sae computer set eshost 0 # Use the following instead if client and server are on different computers #set eshost "myserver.mycompany.mycountry" #set eshost "sgarface2.physics.iastate.edu" set esport 9999 # this is a synchronous connection: # The command does not return until the server responds to the # connection request global io set io [socket -async $eshost $esport] fileevent $io readable {Reader $io} fconfigure $io -blocking 0 -buffering line #=====================================================================