lib/socket: write and read of the native layer use a user-created buffer