Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3155)

Unified Diff: build_tools/debug_server/debug_server/common/debug_socket.h

Issue 6312039: RSP proxy that can record session (for playback testing).... (Closed) Base URL: http://nativeclient-sdk.googlecode.com/svn/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: build_tools/debug_server/debug_server/common/debug_socket.h
===================================================================
--- build_tools/debug_server/debug_server/common/debug_socket.h (revision 0)
+++ build_tools/debug_server/debug_server/common/debug_socket.h (revision 0)
@@ -0,0 +1,60 @@
+#ifndef NACL_SDK_BUILD_TOOLS_DEBUG_SERVER_COMMON_DEBUG_SOCKET_H_
+#define NACL_SDK_BUILD_TOOLS_DEBUG_SERVER_COMMON_DEBUG_SOCKET_H_
+
+#include <winsock.h>
+#include <string>
+#include "debug_blob.h"
+
+namespace debug {
+
+// Implements a listening socket.
+// Example:
+// ListeningSocket lsn;
+// lsn.Setup(4014);
+// Socket conn;
+// if (lsn.Accept(&conn, 200))
+// DoSomethingWithNewConnection(conn);
+
+class Socket;
+class ListeningSocket {
+ public:
+ ListeningSocket();
+ ~ListeningSocket();
+
+ bool Setup(int port); // Listens on port.
+ bool Accept(Socket* new_connection, long wait_ms);
+ void Close();
+
+ protected:
+ SOCKET sock_;
+ bool init_success_;
+};
+
+// Implements a raw socket interface.
+// Example:
+// Socket conn;
+// if (conn.ConnectTo("172.29.20.175", 4016))
+// DoSomethingWithNewConnection(conn);
+
+class Socket {
+ public:
+ Socket();
+ ~Socket();
+
+ bool ConnectTo(const std::string& host, int port);
+ bool IsConnected() const;
+ void Close();
+ size_t Read(void* buff, size_t sz, int wait_ms);
+ size_t Write(const void* buff, size_t sz, int wait_ms);
+ void WriteAll(const void* buff, size_t sz);
+ void WriteAll(const Blob& blob);
+
+ protected:
+ void AttachTo(SOCKET sock);
+
+ SOCKET sock_;
+ bool init_success_;
+ friend class ListeningSocket;
+};
+} // namespace debug
+#endif // NACL_SDK_BUILD_TOOLS_DEBUG_SERVER_COMMON_DEBUG_SOCKET_H_

Powered by Google App Engine
This is Rietveld 408576698