Changed strtok to strtok_r and changed comments
Changed strtok to strtok_r because strtok is not thread safe.
Added the minor code needed for the strtok conversion.
Made some minor changes to the comments as well.
Added additional error checking.
Added check on {HOSTNAME}.dcs.gla.ac.uk