Telnet client IP determination

I have configured my firewall to allow only five remote IP's to connect to my server. Upon connection...i would like to automate the Xsession functions for authorized IP's.

Mainly, $DISPLAY of the environment to the client.

I understand that the "gethostbyaddr" function is capable of this. But this means i would have to make another connection(as in...a separate client-to-server) other than the original telnet to perform this. Correct?

How do i do this without burdening the client with starting two scripts?