as2 and c++ socket communication

I made a simple c++ console application that communicates with a database.
I want to make a flash application to communicate with the console that will in turn grab information from the database and send it back to flash.
Is there a way to do this in as2?
if not how would I accomplish this in as3 or is there an alternative to sockets in as2?
Sample code would be really appreciated.
Please don’t link me to an entire api.

I just need a simple example of how to accomplish sending and receiving data.

bump