| 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 #ifndef BIN_SOCKET_H_ | 5 #ifndef BIN_SOCKET_H_ |
| 6 #define BIN_SOCKET_H_ | 6 #define BIN_SOCKET_H_ |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/utils.h" |
| 9 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| 11 #include "platform/thread.h" |
| 10 | 12 |
| 11 | 13 |
| 12 class Socket { | 14 class Socket { |
| 13 public: | 15 public: |
| 16 enum SocketRequest { |
| 17 kLookupRequest = 0, |
| 18 }; |
| 19 |
| 14 static bool Initialize(); | 20 static bool Initialize(); |
| 15 static intptr_t Available(intptr_t fd); | 21 static intptr_t Available(intptr_t fd); |
| 16 static int Read(intptr_t fd, void* buffer, intptr_t num_bytes); | 22 static int Read(intptr_t fd, void* buffer, intptr_t num_bytes); |
| 17 static int Write(intptr_t fd, const void* buffer, intptr_t num_bytes); | 23 static int Write(intptr_t fd, const void* buffer, intptr_t num_bytes); |
| 18 static intptr_t CreateConnect(const char* host, const intptr_t port); | 24 static intptr_t CreateConnect(const char* host, const intptr_t port); |
| 19 static intptr_t GetPort(intptr_t fd); | 25 static intptr_t GetPort(intptr_t fd); |
| 20 static intptr_t GetStdioHandle(int num); | 26 static intptr_t GetStdioHandle(int num); |
| 21 | 27 |
| 28 // Perform a IPv4 hostname lookup. Returns the hostname string in |
| 29 // IPv4 dotted-decimal format. |
| 30 static const char* LookupIPv4Address(char* host, OSError** os_error); |
| 31 |
| 32 static Dart_Port GetServicePort(); |
| 33 |
| 34 private: |
| 35 static dart::Mutex mutex_; |
| 36 static int service_ports_size_; |
| 37 static Dart_Port* service_ports_; |
| 38 static int service_ports_index_; |
| 39 |
| 22 DISALLOW_ALLOCATION(); | 40 DISALLOW_ALLOCATION(); |
| 23 DISALLOW_IMPLICIT_CONSTRUCTORS(Socket); | 41 DISALLOW_IMPLICIT_CONSTRUCTORS(Socket); |
| 24 }; | 42 }; |
| 25 | 43 |
| 26 | 44 |
| 27 class ServerSocket { | 45 class ServerSocket { |
| 28 public: | 46 public: |
| 29 static intptr_t Accept(intptr_t fd); | 47 static intptr_t Accept(intptr_t fd); |
| 30 static intptr_t CreateBindListen(const char* bindAddress, | 48 static intptr_t CreateBindListen(const char* bindAddress, |
| 31 intptr_t port, | 49 intptr_t port, |
| 32 intptr_t backlog); | 50 intptr_t backlog); |
| 33 | 51 |
| 34 DISALLOW_ALLOCATION(); | 52 DISALLOW_ALLOCATION(); |
| 35 DISALLOW_IMPLICIT_CONSTRUCTORS(ServerSocket); | 53 DISALLOW_IMPLICIT_CONSTRUCTORS(ServerSocket); |
| 36 }; | 54 }; |
| 37 | 55 |
| 38 #endif // BIN_SOCKET_H_ | 56 #endif // BIN_SOCKET_H_ |
| OLD | NEW |