@TCL_STARTUP@

# client.tcl
#
# This is the "client_agent".  It uses agent_meet to establish a direct
# connection with the "server_agent" and exchange status information.  It
# assumes that the "server_agent" is running on the same machine. 

  # register the agent on the current machine

if {[catch agent_begin]} {
  return -code error "ERROR: unable to register the agent on $agent(actual-server)"
}

if {[catch {

    # meet with the "server_agent"

  set handle [agent_meet "$agent(local-ip) server_agent"]

    # exchange status information

  meeting_send $handle 0 "Thank you for accepting the meeting!"
  meeting_receive $handle code string -blocking
  meeting_close $handle

    # display the status information

  puts "$agent(local):\nThe server says ...\n$string"

} error_message]} then {

    # make sure that we clean up on error

  agent_end

  return -code error -errorcode $errorCode -errorinfo $errorInfo $error_message
}

  # clean up
 
agent_end
