Index: net/base/tcp_client_socket_win.cc |
=================================================================== |
--- net/base/tcp_client_socket_win.cc (revision 10055) |
+++ net/base/tcp_client_socket_win.cc (working copy) |
@@ -157,6 +157,22 @@ |
return true; |
} |
+bool TCPClientSocket::IsConnectedAndIdle() const { |
+ if (socket_ == INVALID_SOCKET || wait_state_ == WAITING_CONNECT) |
+ return false; |
+ |
+ // Check if connection is alive and we haven't received any data |
+ // unexpectedly. |
+ char c; |
+ int rv = recv(socket_, &c, 1, MSG_PEEK); |
+ if (rv >= 0) |
+ return false; |
+ if (WSAGetLastError() != WSAEWOULDBLOCK) |
+ return false; |
+ |
+ return true; |
+} |
+ |
int TCPClientSocket::Read(char* buf, |
int buf_len, |
CompletionCallback* callback) { |