FFI wrapper for socket function.