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

Unified Diff: net/socket/tcp_client_socket_win.cc

Issue 10803027: Fix TCPClientSocket::GetLocalAddress() to work when socket is not connected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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_client_socket_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/tcp_client_socket_win.cc
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index aed2adbb85153a41073f2aa1c7659a2b233bde2f..e73c45611fed95aa781c473d550cc29440fa6c66 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -373,7 +373,7 @@ int TCPClientSocketWin::Bind(const IPEndPoint& address) {
if (!address.ToSockAddr(storage.addr, &storage.addr_len))
return ERR_INVALID_ARGUMENT;
- // Create |bound_socket_| and try to bound it to |address|.
+ // Create |bound_socket_| and try to bind it to |address|.
int error = CreateSocket(address.GetFamily(), &bound_socket_);
if (error)
return MapSystemError(error);
@@ -553,8 +553,11 @@ int TCPClientSocketWin::DoConnectComplete(int result) {
}
void TCPClientSocketWin::Disconnect() {
+ DCHECK(CalledOnValidThread());
+
DoDisconnect();
current_address_index_ = -1;
+ bind_address_.reset();
}
void TCPClientSocketWin::DoDisconnect() {
@@ -646,8 +649,13 @@ int TCPClientSocketWin::GetPeerAddress(IPEndPoint* address) const {
int TCPClientSocketWin::GetLocalAddress(IPEndPoint* address) const {
DCHECK(CalledOnValidThread());
DCHECK(address);
- if (!IsConnected())
+ if (socket_ == INVALID_SOCKET) {
+ if (bind_address_.get()) {
+ *address = *bind_address_;
+ return OK;
+ }
return ERR_SOCKET_NOT_CONNECTED;
+ }
struct sockaddr_storage addr_storage;
socklen_t addr_len = sizeof(addr_storage);
« no previous file with comments | « net/socket/tcp_client_socket_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698