Flutter Engine
The Flutter Engine
sync_socket_macos.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_MACOS)
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 Linux.
21 return true;
22}
23
24static intptr_t Create(const RawAddr& addr) {
25 intptr_t fd;
26 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0));
27 if (fd < 0) {
28 return -1;
29 }
30 if (!FDUtils::SetCloseOnExec(fd)) {
32 return -1;
33 }
34 return fd;
35}
36
37static intptr_t Connect(intptr_t fd, const RawAddr& addr) {
38 intptr_t result = TEMP_FAILURE_RETRY(
39 connect(fd, &addr.addr, SocketAddress::GetAddrLength(addr)));
40 if (result == 0) {
41 return fd;
42 }
43 ASSERT(errno != EINPROGRESS);
45 return -1;
46}
47
48intptr_t SynchronousSocket::CreateConnect(const RawAddr& addr) {
49 intptr_t fd = Create(addr);
50 if (fd < 0) {
51 return fd;
52 }
53 return Connect(fd, addr);
54}
55
56intptr_t SynchronousSocket::Available(intptr_t fd) {
58}
59
60intptr_t SynchronousSocket::GetPort(intptr_t fd) {
61 return SocketBase::GetPort(fd);
62}
63
64SocketAddress* SynchronousSocket::GetRemotePeer(intptr_t fd, intptr_t* port) {
66}
67
68intptr_t SynchronousSocket::Read(intptr_t fd,
69 void* buffer,
70 intptr_t num_bytes) {
71 return SocketBase::Read(fd, buffer, num_bytes, SocketBase::kSync);
72}
73
74intptr_t SynchronousSocket::Write(intptr_t fd,
75 const void* buffer,
76 intptr_t num_bytes) {
77 return SocketBase::Write(fd, buffer, num_bytes, SocketBase::kSync);
78}
79
80void SynchronousSocket::ShutdownRead(intptr_t fd) {
81 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_RD));
82}
83
84void SynchronousSocket::ShutdownWrite(intptr_t fd) {
85 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_WR));
86}
87
88void SynchronousSocket::Close(intptr_t fd) {
89 return SocketBase::Close(fd);
90}
91
92} // namespace bin
93} // namespace dart
94
95#endif // defined(DART_HOST_OS_MACOS)
static sk_sp< Effect > Create()
Definition: RefCntTest.cpp:117
static bool SetCloseOnExec(intptr_t fd)
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)