Forum Discussion

dennypayne's avatar
dennypayne
Icon for Employee rankEmployee
Aug 03, 2006

To quote or not to quote

I searched around the TCL reference and this forum and didn't see any discussion of this, maybe I'm missing something obvious but here goes...

Why is this valid:


when CLIENT_ACCEPTED {
     if { [TCP::client_port] equals 80 } {
       pool pool1
     } else {
        discard
  }
}

when this isn't?


when CLIENT_ACCEPTED {
    if { [IP::server_addr] equals 10.0.0.1 } {
       pool pool1
     } else {
      pool pool2
  }
}

The 2nd example errors out saying:

line 2: [parse error: PARSE syntax 62 {syntax error in expression " [IP::server_addr] equals 10.0.0.1 ": extra tokens at end of expression}

However if you put quotes around the address in the 2nd example ("10.0.0.1") it works fine. So why the difference? Do the dots not work in a TCL "word"?

Denny

1 Reply

  • unRuleY pointed out in a past thread, that you should use IP::addr to compare single IP addresses in order to avoid doing a string comparison which apparently is slower.

    
    if { [IP::addr [IP::remote_addr] equals 10.0.0.10] } {
    ...
    }