What exactly are you trying to do? If you just want to get information about the server, you don't have to connect to it. Just ping it, and the pong will contain the information. Have a look at PxL's server info script written in PHP: http://pastebin.com/4u5SdH0q
(be aware that it was written for 1.0, though. Dunno if anything changed in that area with 1.1)
(be aware that it was written for 1.0, though. Dunno if anything changed in that area with 1.1)