Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
sync_socket.h
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#ifndef RUNTIME_BIN_SYNC_SOCKET_H_
6#define RUNTIME_BIN_SYNC_SOCKET_H_
7
8#include "bin/socket_base.h"
9#include "platform/globals.h"
10
11namespace dart {
12namespace bin {
13
15 public:
16 explicit SynchronousSocket(intptr_t fd) : fd_(fd) {}
17 ~SynchronousSocket() { ASSERT(fd_ == kClosedFd); }
18
19 intptr_t fd() const { return fd_; }
20 void SetClosedFd() { fd_ = kClosedFd; }
21
22 static bool Initialize();
23
24 static intptr_t CreateConnect(const RawAddr& addr);
25
27 SynchronousSocket* socket);
29 SynchronousSocket** socket);
30
31 static intptr_t Available(intptr_t fd);
32 static intptr_t GetPort(intptr_t fd);
33 static SocketAddress* GetRemotePeer(intptr_t fd, intptr_t* port);
34 static intptr_t Read(intptr_t fd, void* buffer, intptr_t num_bytes);
35 static intptr_t Write(intptr_t fd, const void* buffer, intptr_t num_bytes);
36
37 static void ShutdownRead(intptr_t fd);
38 static void ShutdownWrite(intptr_t fd);
39 static void Close(intptr_t fd);
40
41 private:
42 static constexpr int kClosedFd = -1;
43
44 intptr_t fd_;
45
47};
48
49} // namespace bin
50} // namespace dart
51
52#endif // RUNTIME_BIN_SYNC_SOCKET_H_
static SocketAddress * GetRemotePeer(intptr_t fd, intptr_t *port)
static intptr_t Available(intptr_t fd)
static Dart_Handle GetSocketIdNativeField(Dart_Handle socket_obj, SynchronousSocket **socket)
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)
static Dart_Handle SetSocketIdNativeField(Dart_Handle handle, SynchronousSocket *socket)
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
#define ASSERT(E)
static const uint8_t buffer[]
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581