Well the first (and easiest) step would be try and make sure sockopen suceeds on port 21, if it doesn't then you know there isn't an ftp server. Next thing you want to check for is probably going to be a 220 reply. The 220 reply looks like:

220 some-text-here
The text can be anything, so just check for the 220. In some circumstances, the server might be busy and to tell you this it will send a 120 reply. Again, you should only ensure that the first word is 120, the text after it will vary. Lastly, it may reply with a 421. This indicates it is an ftp server, but it doesn't want to let you connect. It is possible that other messages might be sent, but those are the standard ones that you should expect.