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

Unified Diff: net/socket/tcp_socket_win.h

Issue 2815993002: Adds a method to TCPServerSocket to adopt a socket. (Closed)
Patch Set: Refined GetSocketDescriptor per review. Created 3 years, 8 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
« no previous file with comments | « net/socket/tcp_socket_unittest.cc ('k') | net/socket/tcp_socket_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/tcp_socket_win.h
diff --git a/net/socket/tcp_socket_win.h b/net/socket/tcp_socket_win.h
index 1cefdca0a2965fe4cab7fa3c7a87be03210c021a..a553e37122518c3b09e657d9a4c6c9bd9a36ec5c 100644
--- a/net/socket/tcp_socket_win.h
+++ b/net/socket/tcp_socket_win.h
@@ -19,6 +19,7 @@
#include "net/base/completion_callback.h"
#include "net/base/net_export.h"
#include "net/log/net_log_with_source.h"
+#include "net/socket/socket_descriptor.h"
#include "net/socket/socket_performance_watcher.h"
namespace net {
@@ -40,12 +41,16 @@ class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe),
int Open(AddressFamily family);
- // Both AdoptConnectedSocket and AdoptListenSocket take ownership of an
- // existing socket. AdoptConnectedSocket takes an already connected
- // socket. AdoptListenSocket takes a socket that is intended to accept
- // connection. In some sense, AdoptListenSocket is more similar to Open.
- int AdoptConnectedSocket(SOCKET socket, const IPEndPoint& peer_address);
- int AdoptListenSocket(SOCKET socket);
+ // Takes ownership of |socket|, which is known to already be connected to the
+ // given peer address. However, peer address may be the empty address, for
+ // compatibility. The given peer address will be returned by GetPeerAddress.
+ int AdoptConnectedSocket(SocketDescriptor socket,
+ const IPEndPoint& peer_address);
+ // Takes ownership of |socket|, which may or may not be open, bound, or
+ // listening. The caller must determine the state of the socket based on its
+ // provenance and act accordingly. The socket may have connections waiting
+ // to be accepted, but must not be actually connected.
+ int AdoptUnconnectedSocket(SocketDescriptor socket);
int Bind(const IPEndPoint& address);
@@ -115,6 +120,11 @@ class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe),
const NetLogWithSource& net_log() const { return net_log_; }
+ // Return the underlying SocketDescriptor and clean up this object, which may
+ // no longer be used. This method should be used only for testing. No read,
+ // write, or accept operations should be pending.
+ SocketDescriptor ReleaseSocketDescriptorForTesting();
+
private:
class Core;
« no previous file with comments | « net/socket/tcp_socket_unittest.cc ('k') | net/socket/tcp_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698