OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "bin/dbg_connection.h" | 5 #include "bin/dbg_connection.h" |
6 #include "bin/dbg_message.h" | 6 #include "bin/dbg_message.h" |
7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
8 #include "bin/log.h" | 8 #include "bin/log.h" |
9 #include "bin/socket.h" | 9 #include "bin/socket.h" |
10 #include "bin/thread.h" | 10 #include "bin/thread.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 287 |
288 // Initialize the socket implementation. | 288 // Initialize the socket implementation. |
289 if (!Socket::Initialize()) { | 289 if (!Socket::Initialize()) { |
290 FATAL("Failed initializing socket implementation."); | 290 FATAL("Failed initializing socket implementation."); |
291 } | 291 } |
292 | 292 |
293 // Now setup a listener socket and start a thread which will | 293 // Now setup a listener socket and start a thread which will |
294 // listen, accept connections from debuggers, read and handle/dispatch | 294 // listen, accept connections from debuggers, read and handle/dispatch |
295 // debugger commands received on these connections. | 295 // debugger commands received on these connections. |
296 ASSERT(listener_fd_ == -1); | 296 ASSERT(listener_fd_ == -1); |
297 listener_fd_ = ServerSocket::CreateBindListen(address, port_number, 1); | 297 |
| 298 OSError *os_error; |
| 299 SocketAddresses* addresses = Socket::LookupAddress(address, -1, &os_error); |
| 300 listener_fd_ = ServerSocket::CreateBindListen( |
| 301 addresses->GetAt(0)->addr(), port_number, 1); |
298 DebuggerConnectionImpl::StartHandler(port_number); | 302 DebuggerConnectionImpl::StartHandler(port_number); |
299 } | 303 } |
300 | 304 |
301 | 305 |
302 void DebuggerConnectionHandler::WaitForConnection() { | 306 void DebuggerConnectionHandler::WaitForConnection() { |
303 MonitorLocker ml(&handler_lock_); | 307 MonitorLocker ml(&handler_lock_); |
304 while (!IsConnected()) { | 308 while (!IsConnected()) { |
305 dart::Monitor::WaitResult res = ml.Wait(); | 309 dart::Monitor::WaitResult res = ml.Wait(); |
306 ASSERT(res == dart::Monitor::kNotified); | 310 ASSERT(res == dart::Monitor::kNotified); |
307 } | 311 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 ASSERT(singleton_handler != NULL); | 439 ASSERT(singleton_handler != NULL); |
436 return singleton_handler; | 440 return singleton_handler; |
437 } | 441 } |
438 | 442 |
439 | 443 |
440 bool DebuggerConnectionHandler::IsConnected() { | 444 bool DebuggerConnectionHandler::IsConnected() { |
441 // TODO(asiva): Support multiple debugger connections. | 445 // TODO(asiva): Support multiple debugger connections. |
442 // Return true if a connection has been established. | 446 // Return true if a connection has been established. |
443 return singleton_handler != NULL; | 447 return singleton_handler != NULL; |
444 } | 448 } |
OLD | NEW |