Flutter Engine
The Flutter Engine
sync_socket_fuchsia.cc
Go to the documentation of this file.
1// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include "platform/globals.h"
6#if defined(DART_HOST_OS_FUCHSIA)
7
8#include "bin/sync_socket.h"
9
10#include <errno.h> // NOLINT
11
12#include "bin/fdutils.h"
13#include "bin/socket_base.h"
15
16namespace dart {
17namespace bin {
18
20 // Nothing to do on Fuchsia.
21 return true;
22}
23
24static intptr_t Create(const RawAddr& addr) {
25 intptr_t fd;
26 intptr_t type = SOCK_STREAM | SOCK_CLOEXEC;
27 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, type, 0));
28 if (fd < 0) {
29 return -1;
30 }
31 return fd;
32}
33
34static intptr_t Connect(intptr_t fd, const RawAddr& addr) {
35 intptr_t result = TEMP_FAILURE_RETRY(
36 connect(fd, &addr.addr, SocketAddress::GetAddrLength(addr)));
37 if (result == 0) {
38 return fd;
39 }
40 ASSERT(errno != EINPROGRESS);
42 return -1;
43}
44
45intptr_t SynchronousSocket::CreateConnect(const RawAddr& addr) {
46 intptr_t fd = Create(addr);
47 if (fd < 0) {
48 return fd;
49 }
50 return Connect(fd, addr);
51}
52
53intptr_t SynchronousSocket::Available(intptr_t fd) {
55}
56
57intptr_t SynchronousSocket::GetPort(intptr_t fd) {
58 return SocketBase::GetPort(fd);
59}
60
61SocketAddress* SynchronousSocket::GetRemotePeer(intptr_t fd, intptr_t* port) {
63}
64
65intptr_t SynchronousSocket::Read(intptr_t fd,
66 void* buffer,
67 intptr_t num_bytes) {
68 return SocketBase::Read(fd, buffer, num_bytes, SocketBase::kSync);
69}
70
71intptr_t SynchronousSocket::Write(intptr_t fd,
72 const void* buffer,
73 intptr_t num_bytes) {
74 return SocketBase::Write(fd, buffer, num_bytes, SocketBase::kSync);
75}
76
77void SynchronousSocket::ShutdownRead(intptr_t fd) {
78 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_RD));
79}
80
81void SynchronousSocket::ShutdownWrite(intptr_t fd) {
82 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_WR));
83}
84
85void SynchronousSocket::Close(intptr_t fd) {
86 return SocketBase::Close(fd);
87}
88
89} // namespace bin
90} // namespace dart
91
92#endif // defined(DART_HOST_OS_FUCHSIA)
static sk_sp< Effect > Create()
Definition: RefCntTest.cpp:117
GLenum type
static void SaveErrorAndClose(intptr_t fd)
static intptr_t GetAddrLength(const RawAddr &addr, bool unnamed_unix_socket=false)
Definition: socket_base.cc:39
static SocketAddress * GetRemotePeer(intptr_t fd, intptr_t *port)
static intptr_t Available(intptr_t fd)
static void Close(intptr_t fd)
static intptr_t Read(intptr_t fd, void *buffer, intptr_t num_bytes, SocketOpKind sync)
static intptr_t Write(intptr_t fd, const void *buffer, intptr_t num_bytes, SocketOpKind sync)
Definition: socket_base.cc:321
static intptr_t GetPort(intptr_t fd)
static SocketAddress * GetRemotePeer(intptr_t fd, intptr_t *port)
static intptr_t Available(intptr_t fd)
static intptr_t CreateConnect(const RawAddr &addr)
static void ShutdownRead(intptr_t fd)
static void Close(intptr_t fd)
static intptr_t Read(intptr_t fd, void *buffer, intptr_t num_bytes)
static intptr_t Write(intptr_t fd, const void *buffer, intptr_t num_bytes)
static intptr_t GetPort(intptr_t fd)
static void ShutdownWrite(intptr_t fd)
#define ASSERT(E)
GAsyncResult * result
Definition: dart_vm.cc:33
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service port
Definition: switches.h:87
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
#define NO_RETRY_EXPECTED(expression)
#define VOID_NO_RETRY_EXPECTED(expression)
#define TEMP_FAILURE_RETRY(expression)