5#ifndef RUNTIME_BIN_SOCKET_H_
6#define RUNTIME_BIN_SOCKET_H_
52 intptr_t
fd()
const {
return fd_; }
118 free(udp_receive_buffer_);
119 udp_receive_buffer_ =
nullptr;
122 static constexpr int kClosedFd = -1;
124 static bool short_socket_read_;
125 static bool short_socket_write_;
130 uint8_t* udp_receive_buffer_;
152 bool v6_only =
false);
161 DISALLOW_ALLOCATION();
168 : sockets_by_port_(SameIntptrValue, kInitialSocketsCount),
169 sockets_by_fd_(SameIntptrValue, kInitialSocketsCount),
170 unix_domain_sockets_(nullptr),
246 static constexpr intptr_t kInitialSocketsCount = 8;
248 OSSocket* FindOSSocketWithAddress(OSSocket* current,
const RawAddr& addr) {
249 while (current !=
nullptr) {
253 current = current->next;
258 OSSocket* FindOSSocketWithPath(OSSocket* current,
261 while (current !=
nullptr) {
262 ASSERT(current->address.addr.sa_family == AF_UNIX);
263#if defined(DART_HOST_OS_LINUX) || defined(DART_HOST_OS_ANDROID)
265 if (path[0] ==
'\0') {
266 condition = current->address.un.sun_path[0] ==
'\0' &&
267 strcmp(&(current->address.un.sun_path[1]), path + 1) == 0;
282 current = current->next;
287 static bool SameIntptrValue(
void* key1,
void* key2) {
288 return reinterpret_cast<intptr_t
>(key1) ==
reinterpret_cast<intptr_t
>(key2);
291 static uint32_t GetHashmapHashFromIntptr(intptr_t i) {
292 return static_cast<uint32_t
>((i + 1) & 0xFFFFFFFF);
295 static void* GetHashmapKeyFromIntptr(intptr_t i) {
296 return reinterpret_cast<void*
>(i + 1);
299 OSSocket* LookupByPort(intptr_t port);
300 void InsertByPort(intptr_t port, OSSocket* socket);
301 void RemoveByPort(intptr_t port);
303 OSSocket* LookupByFd(Socket* fd);
304 void InsertByFd(Socket* fd, OSSocket* socket);
305 void RemoveByFd(Socket* fd);
307 bool CloseOneSafe(OSSocket* os_socket, Socket* socket);
310 SimpleHashMap sockets_by_port_;
311 SimpleHashMap sockets_by_fd_;
313 OSSocket* unix_domain_sockets_;
static Identical AreIdentical(Namespace *namespc_1, const char *file_1, Namespace *namespc_2, const char *file_2)
Dart_Handle CreateBindListen(Dart_Handle socket_object, RawAddr addr, intptr_t backlog, bool v6_only, bool shared)
ListeningSocketRegistry()
bool CloseSafe(Socket *socketfd)
Dart_Handle CreateUnixDomainBindListen(Dart_Handle socket_object, Namespace *namespc, const char *path, intptr_t backlog, bool shared)
~ListeningSocketRegistry()
static ListeningSocketRegistry * Instance()
static intptr_t CreateBindListen(const RawAddr &addr, intptr_t backlog, bool v6_only=false)
static intptr_t Accept(intptr_t fd)
static constexpr intptr_t kTemporaryFailure
static bool StartAccept(intptr_t fd)
static intptr_t CreateUnixDomainBindListen(const RawAddr &addr, intptr_t backlog)
static bool AreAddressesEqual(const RawAddr &a, const RawAddr &b)
static bool IsSignalSocketFlag(intptr_t flag)
static CObject * ListInterfacesRequest(const CObjectArray &request)
static bool short_socket_read()
Dart_Port isolate_port() const
static void set_short_socket_read(bool short_socket_read)
static Dart_Port GetServicePort()
void set_udp_receive_buffer(uint8_t *buffer)
static CObject * ReverseLookupRequest(const CObjectArray &request)
static bool short_socket_write()
static intptr_t CreateUnixDomainConnect(const RawAddr &addr)
uint8_t * udp_receive_buffer() const
static void SetSocketIdNativeField(Dart_Handle handle, intptr_t id, SocketFinalizer finalizer)
static Socket * GetSocketIdNativeField(Dart_Handle socket)
static intptr_t CreateConnect(const RawAddr &addr)
void set_port(Dart_Port port)
static intptr_t CreateBindDatagram(const RawAddr &addr, bool reuseAddress, bool reusePort, int ttl=1)
static void ReuseSocketIdNativeField(Dart_Handle handle, Socket *socket, SocketFinalizer finalizer)
static CObject * LookupRequest(const CObjectArray &request)
static intptr_t CreateBindConnect(const RawAddr &addr, const RawAddr &source_addr)
static intptr_t CreateUnixDomainBindConnect(const RawAddr &addr, const RawAddr &source_addr)
static void set_short_socket_write(bool short_socket_write)
struct _Dart_Handle * Dart_Handle
FlutterSemanticsFlag flag
static const uint8_t buffer[]