Flutter Engine
The Flutter Engine
socket_base_win.cc
Go to the documentation of this file.
1// Copyright (c) 2013, 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_WINDOWS)
7
8#include "bin/socket_base.h"
9
10#include "bin/builtin.h"
11#include "bin/eventhandler.h"
12#include "bin/file.h"
13#include "bin/lockers.h"
14#include "bin/socket_base_win.h"
15#include "bin/thread.h"
16#include "bin/utils.h"
17#include "bin/utils_win.h"
18#include "platform/syslog.h"
19
20namespace dart {
21namespace bin {
22
23SocketAddress::SocketAddress(struct sockaddr* sockaddr,
24 bool unnamed_unix_socket) {
25 // Unix domain sockets not supported on Win. Remove this assert if enabled.
26 ASSERT(!unnamed_unix_socket);
27 ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN);
28 RawAddr* raw = reinterpret_cast<RawAddr*>(sockaddr);
29
30 // Clear the port before calling WSAAddressToString as WSAAddressToString
31 // includes the port in the formatted string.
32 int err =
33 SocketBase::FormatNumericAddress(*raw, as_string_, INET6_ADDRSTRLEN);
34
35 if (err != 0) {
36 as_string_[0] = 0;
37 }
38 memmove(reinterpret_cast<void*>(&addr_), sockaddr,
40}
41
42static Mutex* init_mutex = new Mutex();
43static bool socket_initialized = false;
44
46 MutexLocker lock(init_mutex);
47 if (socket_initialized) {
48 return true;
49 }
50 int err;
51 WSADATA winsock_data;
52 WORD version_requested = MAKEWORD(2, 2);
53 err = WSAStartup(version_requested, &winsock_data);
54 if (err == 0) {
55 socket_initialized = true;
56 } else {
57 Syslog::PrintErr("Unable to initialize Winsock: %d\n", WSAGetLastError());
58 }
59 return (err == 0);
60}
61
62bool SocketBase::FormatNumericAddress(const RawAddr& addr,
63 char* address,
64 int len) {
65 socklen_t salen = SocketAddress::GetAddrLength(addr);
66 DWORD l = len;
67 RawAddr& raw = const_cast<RawAddr&>(addr);
68 wchar_t* waddress = reinterpret_cast<wchar_t*>(
69 Dart_ScopeAllocate((salen + 1) * sizeof(wchar_t)));
70 intptr_t result =
71 WSAAddressToStringW(&raw.addr, salen, nullptr, waddress, &l);
72 if (result != 0) {
73 return true;
74 }
75 WideToUtf8Scope wide_name(waddress);
76 strncpy(address, wide_name.utf8(), l);
77 return false;
78}
79
80intptr_t SocketBase::Available(intptr_t fd) {
81 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd);
82 return client_socket->Available();
83}
84
85intptr_t SocketBase::Read(intptr_t fd,
86 void* buffer,
87 intptr_t num_bytes,
88 SocketOpKind sync) {
89 Handle* handle = reinterpret_cast<Handle*>(fd);
90 return handle->Read(buffer, num_bytes);
91}
92
93intptr_t SocketBase::RecvFrom(intptr_t fd,
94 void* buffer,
95 intptr_t num_bytes,
96 RawAddr* addr,
97 SocketOpKind sync) {
98 Handle* handle = reinterpret_cast<Handle*>(fd);
99 socklen_t addr_len = sizeof(addr->ss);
100 return handle->RecvFrom(buffer, num_bytes, &addr->addr, addr_len);
101}
102
104 return false;
105}
106
107intptr_t SocketBase::ReceiveMessage(intptr_t fd,
108 void* buffer,
109 int64_t* p_buffer_num_bytes,
110 SocketControlMessage** p_messages,
111 SocketOpKind sync,
112 OSError* p_oserror) {
113 errno = ENOSYS;
114 return -1;
115}
116
117bool SocketBase::AvailableDatagram(intptr_t fd,
118 void* buffer,
119 intptr_t num_bytes) {
120 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd);
121 return client_socket->DataReady();
122}
123
124bool SocketBase::HasPendingWrite(intptr_t fd) {
125 Handle* handle = reinterpret_cast<Handle*>(fd);
126 return handle->HasPendingWrite();
127}
128
129intptr_t SocketBase::Write(intptr_t fd,
130 const void* buffer,
131 intptr_t num_bytes,
132 SocketOpKind sync) {
133 Handle* handle = reinterpret_cast<Handle*>(fd);
134 return handle->Write(buffer, num_bytes);
135}
136
137intptr_t SocketBase::SendTo(intptr_t fd,
138 const void* buffer,
139 intptr_t num_bytes,
140 const RawAddr& addr,
141 SocketOpKind sync) {
142 Handle* handle = reinterpret_cast<Handle*>(fd);
143 RawAddr& raw = const_cast<RawAddr&>(addr);
144 return handle->SendTo(buffer, num_bytes, &raw.addr,
146}
147
148intptr_t SocketBase::SendMessage(intptr_t fd,
149 void* buffer,
150 size_t num_bytes,
151 SocketControlMessage* messages,
152 intptr_t num_messages,
153 SocketOpKind sync,
154 OSError* p_oserror) {
155 errno = ENOSYS;
156 return -1;
157}
158
159bool SocketBase::GetSocketName(intptr_t fd, SocketAddress* p_sa) {
160 ASSERT(fd >= 0);
161 ASSERT(p_sa != nullptr);
162 RawAddr raw;
163 socklen_t size = sizeof(raw);
164 if (getsockname(fd, &raw.addr, &size) == SOCKET_ERROR) {
165 return false;
166 }
167
168 // sockaddr_un contains sa_family_t sun_family and char[] sun_path.
169 // If size is the size of sa_family_t, this is an unnamed socket and
170 // sun_path contains garbage.
171 new (p_sa) SocketAddress(&raw.addr,
172 /*unnamed_unix_socket=*/size == sizeof(u_short));
173 return true;
174}
175
176intptr_t SocketBase::GetPort(intptr_t fd) {
177 ASSERT(reinterpret_cast<Handle*>(fd)->is_socket());
178 SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd);
179 RawAddr raw;
180 socklen_t size = sizeof(raw);
181 if (getsockname(socket_handle->socket(), &raw.addr, &size) == SOCKET_ERROR) {
182 return 0;
183 }
184 return SocketAddress::GetAddrPort(raw);
185}
186
187SocketAddress* SocketBase::GetRemotePeer(intptr_t fd, intptr_t* port) {
188 ASSERT(reinterpret_cast<Handle*>(fd)->is_socket());
189 SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd);
190 RawAddr raw;
191 if (socket_handle->is_client_socket() &&
192 reinterpret_cast<ClientSocket*>(fd)->PopulateRemoteAddr(raw)) {
193 // `raw` was populated by `ClientSocket::PopulateRemoteAddr`.
194 } else {
195 socklen_t size = sizeof(raw);
196 if (getpeername(socket_handle->socket(), &raw.addr, &size)) {
197 return nullptr;
198 }
199 }
201 // Clear the port before calling WSAAddressToString as WSAAddressToString
202 // includes the port in the formatted string.
204 return new SocketAddress(&raw.addr);
205}
206
207bool SocketBase::IsBindError(intptr_t error_number) {
208 return error_number == WSAEADDRINUSE || error_number == WSAEADDRNOTAVAIL ||
209 error_number == WSAEINVAL;
210}
211
212void SocketBase::GetError(intptr_t fd, OSError* os_error) {
213 Handle* handle = reinterpret_cast<Handle*>(fd);
214 os_error->SetCodeAndMessage(OSError::kSystem, handle->last_error());
215}
216
217int SocketBase::GetType(intptr_t fd) {
218 Handle* handle = reinterpret_cast<Handle*>(fd);
219 switch (GetFileType(handle->handle())) {
220 case FILE_TYPE_CHAR:
221 return File::kTerminal;
222 case FILE_TYPE_PIPE:
223 return File::kPipe;
224 case FILE_TYPE_DISK:
225 return File::kFile;
226 default:
227 return GetLastError() == NO_ERROR ? File::kOther : -1;
228 }
229}
230
231intptr_t SocketBase::GetStdioHandle(intptr_t num) {
232 if (num != 0) {
233 return -1;
234 }
235 HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
236 if (handle == INVALID_HANDLE_VALUE) {
237 return -1;
238 }
239 StdHandle* std_handle = StdHandle::Stdin(handle);
240 std_handle->Retain();
241 std_handle->MarkDoesNotSupportOverlappedIO();
242 std_handle->EnsureInitialized(EventHandler::delegate());
243 return reinterpret_cast<intptr_t>(std_handle);
244}
245
246AddressList<SocketAddress>* SocketBase::LookupAddress(const char* host,
247 int type,
248 OSError** os_error) {
249 Initialize();
250
251 // Perform a name lookup for a host name.
252 struct addrinfo hints;
253 memset(&hints, 0, sizeof(hints));
254 hints.ai_family = SocketAddress::FromType(type);
255 hints.ai_socktype = SOCK_STREAM;
256 hints.ai_flags = AI_ADDRCONFIG;
257 hints.ai_protocol = IPPROTO_TCP;
258 struct addrinfo* info = nullptr;
259 int status = getaddrinfo(host, 0, &hints, &info);
260 if (status != 0) {
261 // We failed, try without AI_ADDRCONFIG. This can happen when looking up
262 // e.g. '::1', when there are no global IPv6 addresses.
263 hints.ai_flags = 0;
264 status = getaddrinfo(host, 0, &hints, &info);
265 }
266 if (status != 0) {
267 ASSERT(*os_error == nullptr);
268 DWORD error_code = WSAGetLastError();
269 SetLastError(error_code);
270 *os_error = new OSError();
271 return nullptr;
272 }
273 intptr_t count = 0;
274 for (struct addrinfo* c = info; c != nullptr; c = c->ai_next) {
275 if ((c->ai_family == AF_INET) || (c->ai_family == AF_INET6)) {
276 count++;
277 }
278 }
279 AddressList<SocketAddress>* addresses = new AddressList<SocketAddress>(count);
280 intptr_t i = 0;
281 for (struct addrinfo* c = info; c != nullptr; c = c->ai_next) {
282 if ((c->ai_family == AF_INET) || (c->ai_family == AF_INET6)) {
283 addresses->SetAt(i, new SocketAddress(c->ai_addr));
284 i++;
285 }
286 }
287 freeaddrinfo(info);
288 return addresses;
289}
290
291bool SocketBase::ReverseLookup(const RawAddr& addr,
292 char* host,
293 intptr_t host_len,
294 OSError** os_error) {
295 ASSERT(host_len >= NI_MAXHOST);
296 int status = getnameinfo(&addr.addr, SocketAddress::GetAddrLength(addr), host,
297 host_len, nullptr, 0, NI_NAMEREQD);
298 if (status != 0) {
299 ASSERT(*os_error == nullptr);
300 DWORD error_code = WSAGetLastError();
301 SetLastError(error_code);
302 *os_error = new OSError();
303 return false;
304 }
305 return true;
306}
307
308bool SocketBase::ParseAddress(int type, const char* address, RawAddr* addr) {
309 int result;
310 const auto system_address = Utf8ToWideChar(address);
312 result = InetPton(AF_INET, system_address.get(), &addr->in.sin_addr);
313 } else {
315 result = InetPton(AF_INET6, system_address.get(), &addr->in6.sin6_addr);
316 }
317 return result == 1;
318}
319
320bool SocketBase::RawAddrToString(RawAddr* addr, char* str) {
321 // According to InetNtopW(), buffer should be large enough for at least 46
322 // characters for IPv6 and 16 for IPv4.
323 COMPILE_ASSERT(INET6_ADDRSTRLEN >= 46);
324 wchar_t tmp_buffer[INET6_ADDRSTRLEN];
325 if (addr->addr.sa_family == AF_INET) {
326 if (InetNtop(AF_INET, &addr->in.sin_addr, tmp_buffer, INET_ADDRSTRLEN) ==
327 nullptr) {
328 return false;
329 }
330 } else {
331 ASSERT(addr->addr.sa_family == AF_INET6);
332 if (InetNtop(AF_INET6, &addr->in6.sin6_addr, tmp_buffer,
333 INET6_ADDRSTRLEN) == nullptr) {
334 return false;
335 }
336 }
337 WideToUtf8Scope wide_to_utf8_scope(tmp_buffer);
338 if (wide_to_utf8_scope.length() <= INET6_ADDRSTRLEN) {
339 strncpy(str, wide_to_utf8_scope.utf8(), INET6_ADDRSTRLEN);
340 return true;
341 }
342 return false;
343}
344
345AddressList<InterfaceSocketAddress>* SocketBase::ListInterfaces(
346 int type,
347 OSError** os_error) {
348 Initialize();
349
350 ULONG size = 0;
351 DWORD flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST |
352 GAA_FLAG_SKIP_DNS_SERVER;
353 // Query the size needed.
354 int status = GetAdaptersAddresses(SocketAddress::FromType(type), flags,
355 nullptr, nullptr, &size);
356 IP_ADAPTER_ADDRESSES* addrs = nullptr;
357 if (status == ERROR_BUFFER_OVERFLOW) {
358 addrs = reinterpret_cast<IP_ADAPTER_ADDRESSES*>(malloc(size));
359 // Get the addresses now we have the right buffer.
360 status = GetAdaptersAddresses(SocketAddress::FromType(type), flags, nullptr,
361 addrs, &size);
362 }
363 if (status != NO_ERROR) {
364 ASSERT(*os_error == nullptr);
365 DWORD error_code = WSAGetLastError();
366 SetLastError(error_code);
367 *os_error = new OSError();
368 return nullptr;
369 }
370 intptr_t count = 0;
371 for (IP_ADAPTER_ADDRESSES* a = addrs; a != nullptr; a = a->Next) {
372 for (IP_ADAPTER_UNICAST_ADDRESS* u = a->FirstUnicastAddress; u != nullptr;
373 u = u->Next) {
374 count++;
375 }
376 }
377 AddressList<InterfaceSocketAddress>* addresses =
378 new AddressList<InterfaceSocketAddress>(count);
379 intptr_t i = 0;
380 for (IP_ADAPTER_ADDRESSES* a = addrs; a != nullptr; a = a->Next) {
381 for (IP_ADAPTER_UNICAST_ADDRESS* u = a->FirstUnicastAddress; u != nullptr;
382 u = u->Next) {
383 ASSERT(type != AF_INET || a->Flags & IP_ADAPTER_IPV4_ENABLED);
384 ASSERT(type != AF_INET6 || a->Flags & IP_ADAPTER_IPV6_ENABLED);
385 ASSERT(a->IfIndex == a->Ipv6IfIndex ||
386 !(a->Flags & IP_ADAPTER_IPV4_ENABLED) ||
387 !(a->Flags & IP_ADAPTER_IPV6_ENABLED));
388 addresses->SetAt(i,
389 new InterfaceSocketAddress(
390 u->Address.lpSockaddr,
391 StringUtilsWin::WideToUtf8(a->FriendlyName),
392 a->Ipv6IfIndex != 0 ? a->Ipv6IfIndex : a->IfIndex));
393 i++;
394 }
395 }
396 free(addrs);
397 return addresses;
398}
399
400void SocketBase::Close(intptr_t fd) {
401 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd);
402 client_socket->Close();
403}
404
405bool SocketBase::GetNoDelay(intptr_t fd, bool* enabled) {
406 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
407 int on;
408 socklen_t len = sizeof(on);
409 int err = getsockopt(handle->socket(), IPPROTO_TCP, TCP_NODELAY,
410 reinterpret_cast<char*>(&on), &len);
411 if (err == 0) {
412 *enabled = (on == 1);
413 }
414 return (err == 0);
415}
416
417bool SocketBase::SetNoDelay(intptr_t fd, bool enabled) {
418 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
419 int on = enabled ? 1 : 0;
420 return setsockopt(handle->socket(), IPPROTO_TCP, TCP_NODELAY,
421 reinterpret_cast<char*>(&on), sizeof(on)) == 0;
422}
423
424bool SocketBase::GetMulticastLoop(intptr_t fd,
425 intptr_t protocol,
426 bool* enabled) {
427 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
428 uint8_t on;
429 socklen_t len = sizeof(on);
430 int level = protocol == SocketAddress::TYPE_IPV4 ? IPPROTO_IP : IPPROTO_IPV6;
431 int optname = protocol == SocketAddress::TYPE_IPV4 ? IP_MULTICAST_LOOP
432 : IPV6_MULTICAST_LOOP;
433 if (getsockopt(handle->socket(), level, optname, reinterpret_cast<char*>(&on),
434 &len) == 0) {
435 *enabled = (on == 1);
436 return true;
437 }
438 return false;
439}
440
441bool SocketBase::SetMulticastLoop(intptr_t fd,
442 intptr_t protocol,
443 bool enabled) {
444 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
445 int on = enabled ? 1 : 0;
446 int level = protocol == SocketAddress::TYPE_IPV4 ? IPPROTO_IP : IPPROTO_IPV6;
447 int optname = protocol == SocketAddress::TYPE_IPV4 ? IP_MULTICAST_LOOP
448 : IPV6_MULTICAST_LOOP;
449 return setsockopt(handle->socket(), level, optname,
450 reinterpret_cast<char*>(&on), sizeof(on)) == 0;
451}
452
453bool SocketBase::GetMulticastHops(intptr_t fd, intptr_t protocol, int* value) {
454 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
455 uint8_t v;
456 socklen_t len = sizeof(v);
457 int level = protocol == SocketAddress::TYPE_IPV4 ? IPPROTO_IP : IPPROTO_IPV6;
458 int optname = protocol == SocketAddress::TYPE_IPV4 ? IP_MULTICAST_TTL
459 : IPV6_MULTICAST_HOPS;
460 if (getsockopt(handle->socket(), level, optname, reinterpret_cast<char*>(&v),
461 &len) == 0) {
462 *value = v;
463 return true;
464 }
465 return false;
466}
467
468bool SocketBase::SetMulticastHops(intptr_t fd, intptr_t protocol, int value) {
469 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
470 int v = value;
471 int level = protocol == SocketAddress::TYPE_IPV4 ? IPPROTO_IP : IPPROTO_IPV6;
472 int optname = protocol == SocketAddress::TYPE_IPV4 ? IP_MULTICAST_TTL
473 : IPV6_MULTICAST_HOPS;
474 return setsockopt(handle->socket(), level, optname,
475 reinterpret_cast<char*>(&v), sizeof(v)) == 0;
476}
477
478bool SocketBase::GetBroadcast(intptr_t fd, bool* enabled) {
479 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
480 int on;
481 socklen_t len = sizeof(on);
482 int err = getsockopt(handle->socket(), SOL_SOCKET, SO_BROADCAST,
483 reinterpret_cast<char*>(&on), &len);
484 if (err == 0) {
485 *enabled = (on == 1);
486 }
487 return (err == 0);
488}
489
490bool SocketBase::SetBroadcast(intptr_t fd, bool enabled) {
491 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
492 int on = enabled ? 1 : 0;
493 return setsockopt(handle->socket(), SOL_SOCKET, SO_BROADCAST,
494 reinterpret_cast<char*>(&on), sizeof(on)) == 0;
495}
496
497bool SocketBase::SetOption(intptr_t fd,
498 int level,
499 int option,
500 const char* data,
501 int length) {
502 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
503 return setsockopt(handle->socket(), level, option, data, length) == 0;
504}
505
506bool SocketBase::GetOption(intptr_t fd,
507 int level,
508 int option,
509 char* data,
510 unsigned int* length) {
511 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
512 int optlen = static_cast<int>(*length);
513 auto result = getsockopt(handle->socket(), level, option, data, &optlen);
514 *length = static_cast<unsigned int>(optlen);
515 return result == 0;
516}
517
518bool SocketBase::JoinMulticast(intptr_t fd,
519 const RawAddr& addr,
520 const RawAddr&,
521 int interfaceIndex) {
522 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
523 int proto = addr.addr.sa_family == AF_INET ? IPPROTO_IP : IPPROTO_IPV6;
524 struct group_req mreq;
525 mreq.gr_interface = interfaceIndex;
526 memmove(&mreq.gr_group, &addr.ss, SocketAddress::GetAddrLength(addr));
527 return setsockopt(handle->socket(), proto, MCAST_JOIN_GROUP,
528 reinterpret_cast<char*>(&mreq), sizeof(mreq)) == 0;
529}
530
531bool SocketBase::LeaveMulticast(intptr_t fd,
532 const RawAddr& addr,
533 const RawAddr&,
534 int interfaceIndex) {
535 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
536 int proto = addr.addr.sa_family == AF_INET ? IPPROTO_IP : IPPROTO_IPV6;
537 struct group_req mreq;
538 mreq.gr_interface = interfaceIndex;
539 memmove(&mreq.gr_group, &addr.ss, SocketAddress::GetAddrLength(addr));
540 return setsockopt(handle->socket(), proto, MCAST_LEAVE_GROUP,
541 reinterpret_cast<char*>(&mreq), sizeof(mreq)) == 0;
542}
543
544} // namespace bin
545} // namespace dart
546
547#endif // defined(DART_HOST_OS_WINDOWS)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
int count
Definition: FontMgrTest.cpp:50
GLenum type
static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static EventHandlerImplementation * delegate()
Definition: eventhandler.cc:64
static int16_t FromType(int type)
Definition: socket_base.cc:163
static void SetAddrPort(RawAddr *addr, intptr_t port)
Definition: socket_base.cc:177
static intptr_t GetAddrLength(const RawAddr &addr, bool unnamed_unix_socket=false)
Definition: socket_base.cc:39
SocketAddress(struct sockaddr *sa, bool unnamed_unix_socket=false)
static intptr_t GetAddrPort(const RawAddr &addr)
Definition: socket_base.cc:187
static bool LeaveMulticast(intptr_t fd, const RawAddr &addr, const RawAddr &interface, int interfaceIndex)
static bool AvailableDatagram(intptr_t fd, void *buffer, intptr_t num_bytes)
static int GetType(intptr_t fd)
static AddressList< SocketAddress > * LookupAddress(const char *host, int type, OSError **os_error)
static bool SetMulticastHops(intptr_t fd, intptr_t protocol, int value)
static intptr_t GetStdioHandle(intptr_t num)
static intptr_t ReceiveMessage(intptr_t fd, void *buffer, int64_t *p_buffer_num_bytes, SocketControlMessage **p_messages, SocketOpKind sync, OSError *p_oserror)
static bool SetOption(intptr_t fd, int level, int option, const char *data, int length)
static SocketAddress * GetRemotePeer(intptr_t fd, intptr_t *port)
static bool FormatNumericAddress(const RawAddr &addr, char *address, int len)
static bool SetNoDelay(intptr_t fd, bool enabled)
static bool GetSocketName(intptr_t fd, SocketAddress *p_sa)
static bool ParseAddress(int type, const char *address, RawAddr *addr)
static intptr_t Available(intptr_t fd)
static void Close(intptr_t fd)
static void GetError(intptr_t fd, OSError *os_error)
static intptr_t RecvFrom(intptr_t fd, void *buffer, intptr_t num_bytes, RawAddr *addr, SocketOpKind sync)
static bool IsBindError(intptr_t error_number)
static intptr_t Read(intptr_t fd, void *buffer, intptr_t num_bytes, SocketOpKind sync)
static bool SetBroadcast(intptr_t fd, bool value)
static bool GetNoDelay(intptr_t fd, bool *enabled)
static bool SetMulticastLoop(intptr_t fd, intptr_t protocol, bool enabled)
static bool GetOption(intptr_t fd, int level, int option, char *data, unsigned int *length)
static bool ReverseLookup(const RawAddr &addr, char *host, intptr_t host_len, OSError **os_error)
static bool Initialize()
static bool RawAddrToString(RawAddr *addr, char *str)
static intptr_t SendTo(intptr_t fd, const void *buffer, intptr_t num_bytes, const RawAddr &addr, SocketOpKind sync)
static bool GetMulticastHops(intptr_t fd, intptr_t protocol, int *value)
static bool GetMulticastLoop(intptr_t fd, intptr_t protocol, bool *enabled)
static bool JoinMulticast(intptr_t fd, const RawAddr &addr, const RawAddr &interface, int interfaceIndex)
static intptr_t SendMessage(intptr_t fd, void *buffer, size_t buffer_num_bytes, SocketControlMessage *messages, intptr_t num_messages, SocketOpKind sync, OSError *p_oserror)
static AddressList< InterfaceSocketAddress > * ListInterfaces(int type, OSError **os_error)
static bool GetBroadcast(intptr_t fd, bool *value)
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 StdHandle * Stdin(HANDLE handle)
static char * WideToUtf8(wchar_t *wide, intptr_t len=-1, intptr_t *result_len=nullptr)
#define ASSERT(E)
struct MyStruct a[10]
FlutterSemanticsFlag flags
uint8_t value
GAsyncResult * result
size_t length
std::unique_ptr< wchar_t[]> Utf8ToWideChar(const char *path)
Definition: dart_vm.cc:33
void * malloc(size_t size)
Definition: allocation.cc:19
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)
static int8_t data[kExtLength]
COMPILE_ASSERT(kUnreachableReference==WeakTable::kNoValue)
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 host
Definition: switches.h:74
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
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
unsigned short WORD
Definition: windows_types.h:41
#define INVALID_HANDLE_VALUE
WINBASEAPI VOID WINAPI SetLastError(_In_ DWORD dwErrCode)
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI GetLastError(VOID)
void * HANDLE
Definition: windows_types.h:36
DWORD ULONG
Definition: windows_types.h:40
unsigned long DWORD
Definition: windows_types.h:22