| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/socket/tcp_client_socket_win.h" | 5 #include "net/socket/tcp_client_socket_win.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory_debug.h" | 9 #include "base/memory_debug.h" |
| 10 #include "base/stats_counters.h" | 10 #include "base/stats_counters.h" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 char c; | 428 char c; |
| 429 int rv = recv(socket_, &c, 1, MSG_PEEK); | 429 int rv = recv(socket_, &c, 1, MSG_PEEK); |
| 430 if (rv >= 0) | 430 if (rv >= 0) |
| 431 return false; | 431 return false; |
| 432 if (WSAGetLastError() != WSAEWOULDBLOCK) | 432 if (WSAGetLastError() != WSAEWOULDBLOCK) |
| 433 return false; | 433 return false; |
| 434 | 434 |
| 435 return true; | 435 return true; |
| 436 } | 436 } |
| 437 | 437 |
| 438 int TCPClientSocketWin::GetPeerName(struct sockaddr* name, | 438 int TCPClientSocketWin::GetPeerAddress(AddressList* address) const { |
| 439 socklen_t* namelen) { | 439 DCHECK(address); |
| 440 return getpeername(socket_, name, namelen); | 440 if (!current_ai_) |
| 441 return ERR_FAILED; |
| 442 address->Copy(current_ai_, false); |
| 443 return OK; |
| 441 } | 444 } |
| 442 | 445 |
| 443 int TCPClientSocketWin::Read(IOBuffer* buf, | 446 int TCPClientSocketWin::Read(IOBuffer* buf, |
| 444 int buf_len, | 447 int buf_len, |
| 445 CompletionCallback* callback) { | 448 CompletionCallback* callback) { |
| 446 DCHECK_NE(socket_, INVALID_SOCKET); | 449 DCHECK_NE(socket_, INVALID_SOCKET); |
| 447 DCHECK(!waiting_read_); | 450 DCHECK(!waiting_read_); |
| 448 DCHECK(!read_callback_); | 451 DCHECK(!read_callback_); |
| 449 DCHECK(!core_->read_iobuffer_); | 452 DCHECK(!core_->read_iobuffer_); |
| 450 | 453 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 waiting_write_ = false; | 697 waiting_write_ = false; |
| 695 if (ok) { | 698 if (ok) { |
| 696 CHECK(num_bytes <= core_->write_buffer_length_) << | 699 CHECK(num_bytes <= core_->write_buffer_length_) << |
| 697 core_->write_buffer_length_; | 700 core_->write_buffer_length_; |
| 698 } | 701 } |
| 699 core_->write_iobuffer_ = NULL; | 702 core_->write_iobuffer_ = NULL; |
| 700 DoWriteCallback(ok ? num_bytes : MapWinsockError(WSAGetLastError())); | 703 DoWriteCallback(ok ? num_bytes : MapWinsockError(WSAGetLastError())); |
| 701 } | 704 } |
| 702 | 705 |
| 703 } // namespace net | 706 } // namespace net |
| OLD | NEW |