PBXIAF, FreePBX and "API"

I’m testing out using FreePBX as a replacement phone system. I’ve setup a VM (PBXIAF Green) added a few test SIP extensions etc. Now I’m looking to dive into the API, capturing/monitoring events, etc. I attempted to use a C# DLL library from sourceforge to connect to the AMI manager in my FreePBX. However, I’m getting Socket Exceptions (which unfortunately, I cannot debug as I can’t see the exception coming from the library), and the libraries client eventually fires off a timeout exception with the message that it cannot determine the protocol.

How does the AMI connection work with FreePBX? Can anyone offer me some insight? I’ve been researching this to no end and am coming up short.

fsocketopen though PHP