It's pretty easy. I had a post that talked about sending to a remote GF server (the post is from within an app server context, but the code is identical if it is outside; you just have to have the right server jars on your classpath).
Of specific interest to you should be the information about setting the sys props that will register the context factory, remote host and ports to use. I suggest reading the whole post, because some quirks are found and solutions to them are presented.
http://forums.java.net/jive/thread.jspa?messageID=272823񂦷
You should be able to search the glassfish docs for more information about connecting as a client.
Good luck
[Message sent by forum member 'asherwin' (asherwin)]
http://forums.java.net/jive/thread.jspa?messageID=283073