1 // Copyright 2016 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <lib/zx/socket.h>
6 
7 #include <zircon/syscalls.h>
8 
9 namespace zx {
10 
create(uint32_t flags,socket * endpoint0,socket * endpoint1)11 zx_status_t socket::create(uint32_t flags, socket* endpoint0,
12                            socket* endpoint1) {
13     // Ensure aliasing of both out parameters to the same container
14     // has a well-defined result, and does not leak.
15     socket h0;
16     socket h1;
17     zx_status_t status = zx_socket_create(
18         flags, h0.reset_and_get_address(),
19         h1.reset_and_get_address());
20     endpoint0->reset(h0.release());
21     endpoint1->reset(h1.release());
22     return status;
23 }
24 
25 } // namespace zx
26