Working with sockets

I am trying to create a client to connect to a mysql database using sockets. I have the following code but of course, its not working to my advantage. Right now, this code connects to a server file located on a linux machine...i havent coded it yet to connect to a database. What is the best approach when trying to connect to a database so I have the option to add/delete/view information on my database. I been reading up on the MYSQL API but I want to see if its possible through sockets and if so how? Here is the code i have thus far: