added some sample code for socket opening