# Connection sample

    source ../../oo.tcl

    @import core.*

    #- creating connection with localhost at port: 2002
    c = [[[Connection new] host: localhost] port: 2002]

    #- opening it
    if [catch {$c open} err] {
      puts stderr $err
      exit 1
    }

    #- sending 5 messages to server
    foreach i {1 2 3 4 5} {
      if [$c isAlive] {
        puts stderr "sending \"Hello $i from client\""
        if [catch {$c send: "Hello $i from client"} err] {
          puts stderr $err ; break
        }
        if [catch {puts stderr "got \"[$c receive]\""} err] {
          puts stderr $err ; break
        }
      }
    }

    #- closing it
    $c close

    #- releasing connection
    $c release