OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2011 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can | |
4 * be found in the LICENSE file. | |
5 */ | |
6 | |
7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_DEBUG_STUB_DEBUG_SOCKET_H_ | |
8 #define NATIVE_CLIENT_SRC_TRUSTED_DEBUG_STUB_DEBUG_SOCKET_H_ 1 | |
9 | |
10 #include "debug_conn/debug_socket_impl.h" | |
11 #include "debug_conn/debug_stream.h" | |
12 #include "native_client/src/include/portability.h" | |
13 | |
14 namespace nacl_debug_conn { | |
15 | |
16 class DebugSocket : public DebugStream { | |
17 public: | |
18 enum DSState { | |
19 DSS_INVALID = 0, // No Socket | |
20 DSS_UNBOUND = 1, // Has Socket, but is unbound | |
21 DSS_BOUND = 2, // Socket has been bound | |
22 DSS_LISTEN = 3, // Socket is listening for connections | |
23 DSS_CONNECTED = 4 // Socket is connected | |
24 }; | |
25 | |
26 public: | |
27 virtual ~DebugSocket(); | |
28 | |
29 public: | |
30 static DebugSocket *CreateServer(const char *addr, int outstanding); | |
31 static DebugSocket *CreateClient(const char *addr); | |
32 DebugSocket *Accept(); | |
33 | |
34 public: | |
35 int32_t Read(void *ptr, int32_t len); | |
36 int32_t Write(void *ptr, int32_t len); | |
37 bool IsConnected() const; | |
38 bool DataAvail() const; | |
39 | |
40 protected: | |
41 DSState GetState() const; | |
42 void SetState(DSState state); | |
43 | |
44 uint32_t GetTimeout() const; | |
45 void SetTimeout(uint32_t msec); | |
46 | |
47 private: | |
48 DebugSocket(); | |
49 bool Construct(); | |
50 void Destruct(); | |
51 | |
52 void* GetHandle() const; | |
53 void SetHandle(void *h); | |
54 | |
55 private: | |
56 DSState state_; | |
57 DSHandle handle_; | |
58 uint32_t msec_timeout_; | |
59 }; | |
60 | |
61 } // namespace nacl_debug_conn | |
62 #endif | |
63 | |
OLD | NEW |