summaryrefslogtreecommitdiffstats
path: root/net/socket/tcp_client_socket_win.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 01:11:53 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 01:11:53 +0000
commitaa4861088333f8cb2638a8a42ff35f2e42834576 (patch)
tree3447b65520012c7739809ec5239bebdbd5846963 /net/socket/tcp_client_socket_win.cc
parentebe42d99cfd8217f70c42b1411bbecd3ba5759ca (diff)
downloadchromium_src-aa4861088333f8cb2638a8a42ff35f2e42834576.zip
chromium_src-aa4861088333f8cb2638a8a42ff35f2e42834576.tar.gz
chromium_src-aa4861088333f8cb2638a8a42ff35f2e42834576.tar.bz2
Fix TCPClientSocket::GetLocalAddress() to work when socket is not connected.
BUG=118312 Review URL: https://chromiumcodereview.appspot.com/10803027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147586 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/tcp_client_socket_win.cc')
-rw-r--r--net/socket/tcp_client_socket_win.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index 74fa99e..3fda1bc 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);