Add MacOSX compatability

Add compatibility for MacOSX implementation of sockets.