98 {
99 MutexLocker ml(&mutex_);
100
101 OSSocket* first_os_socket = nullptr;
104 first_os_socket = LookupByPort(
port);
105 if (first_os_socket != nullptr) {
106
107
108
109 OSSocket* os_socket = first_os_socket;
110 OSSocket* os_socket_same_addr = FindOSSocketWithAddress(os_socket,
addr);
111
112 if (os_socket_same_addr != nullptr) {
113 if (!os_socket_same_addr->shared || !shared) {
114 OSError os_error(-1,
115 "The shared flag to bind() needs to be `true` if "
116 "binding multiple times on the same (address, port) "
117 "combination.",
120 }
121 if (os_socket_same_addr->v6_only != v6_only) {
122 OSError os_error(-1,
123 "The v6Only flag to bind() needs to be the same if "
124 "binding multiple times on the same (address, port) "
125 "combination.",
128 }
129
130
131
132
133
134 Socket* socketfd = new Socket(os_socket_same_addr->fd);
135 os_socket_same_addr->ref_count++;
136
137
140 InsertByFd(socketfd, os_socket_same_addr);
142 }
143 }
144 }
145
146
148 if (fd == -5) {
151 }
152 if (fd < 0) {
155 }
159 }
161 ASSERT(allocated_port > 0);
162
163 if (allocated_port !=
port) {
164
165
166
167
168
169
170
171
172
173
174
175
176
178 first_os_socket = LookupByPort(allocated_port);
179 }
180
181 Socket* socketfd = new Socket(fd);
182 OSSocket* os_socket =
183 new OSSocket(
addr, allocated_port, v6_only, shared, socketfd,
nullptr);
184 os_socket->ref_count = 1;
185 os_socket->next = first_os_socket;
186
187 InsertByPort(allocated_port, os_socket);
188 InsertByFd(socketfd, os_socket);
189
190
193
195}
static Dart_Handle NewDartOSError()
static intptr_t CreateBindListen(const RawAddr &addr, intptr_t backlog, bool v6_only=false)
static bool StartAccept(intptr_t fd)
static intptr_t GetAddrPort(const RawAddr &addr)
static intptr_t GetPort(intptr_t fd)
static void ReuseSocketIdNativeField(Dart_Handle handle, Socket *socket, SocketFinalizer finalizer)
const uint8_t uint32_t uint32_t GError ** error
DART_EXPORT Dart_Handle Dart_True()
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