I don't have a ton of experience with the TCL scan command but, here is my 2 cents:
It seems like this command parses the last octet from an IP address. If this command is executed in a client side event, then the remote addr is the client IP address. If it executes in a server side event, then the remote addr is the server IP address.
Either way, the scan command seems to be pulling the last octect and checking if it is a decimal number. that decimal is then put into the variable S4.
There must be more to this though because, what else would the [IP::remote_addr] return besides a series of numbers.
HTH.