| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "net/socket/tcp_client_socket.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <netdb.h> | 9 #include <netdb.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Cannot bind the socket if we are already bound connected or | 174 // Cannot bind the socket if we are already bound connected or |
| 175 // connecting. | 175 // connecting. |
| 176 return ERR_UNEXPECTED; | 176 return ERR_UNEXPECTED; |
| 177 } | 177 } |
| 178 | 178 |
| 179 SockaddrStorage storage; | 179 SockaddrStorage storage; |
| 180 if (!address.ToSockAddr(storage.addr, &storage.addr_len)) | 180 if (!address.ToSockAddr(storage.addr, &storage.addr_len)) |
| 181 return ERR_INVALID_ARGUMENT; | 181 return ERR_INVALID_ARGUMENT; |
| 182 | 182 |
| 183 // Create |bound_socket_| and try to bind it to |address|. | 183 // Create |bound_socket_| and try to bind it to |address|. |
| 184 int error = CreateSocket(address.GetFamily(), &bound_socket_); | 184 int error = CreateSocket(address.GetSockAddrFamily(), &bound_socket_); |
| 185 if (error) | 185 if (error) |
| 186 return MapSystemError(error); | 186 return MapSystemError(error); |
| 187 | 187 |
| 188 if (HANDLE_EINTR(bind(bound_socket_, storage.addr, storage.addr_len))) { | 188 if (HANDLE_EINTR(bind(bound_socket_, storage.addr, storage.addr_len))) { |
| 189 error = errno; | 189 error = errno; |
| 190 if (HANDLE_EINTR(close(bound_socket_)) < 0) | 190 if (HANDLE_EINTR(close(bound_socket_)) < 0) |
| 191 PLOG(ERROR) << "close"; | 191 PLOG(ERROR) << "close"; |
| 192 bound_socket_ = kInvalidSocket; | 192 bound_socket_ = kInvalidSocket; |
| 193 return MapSystemError(error); | 193 return MapSystemError(error); |
| 194 } | 194 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 CreateNetLogIPEndPointCallback(&endpoint)); | 271 CreateNetLogIPEndPointCallback(&endpoint)); |
| 272 | 272 |
| 273 next_connect_state_ = CONNECT_STATE_CONNECT_COMPLETE; | 273 next_connect_state_ = CONNECT_STATE_CONNECT_COMPLETE; |
| 274 | 274 |
| 275 if (bound_socket_ != kInvalidSocket) { | 275 if (bound_socket_ != kInvalidSocket) { |
| 276 DCHECK(bind_address_.get()); | 276 DCHECK(bind_address_.get()); |
| 277 socket_ = bound_socket_; | 277 socket_ = bound_socket_; |
| 278 bound_socket_ = kInvalidSocket; | 278 bound_socket_ = kInvalidSocket; |
| 279 } else { | 279 } else { |
| 280 // Create a non-blocking socket. | 280 // Create a non-blocking socket. |
| 281 connect_os_error_ = CreateSocket(endpoint.GetFamily(), &socket_); | 281 connect_os_error_ = CreateSocket(endpoint.GetSockAddrFamily(), &socket_); |
| 282 if (connect_os_error_) | 282 if (connect_os_error_) |
| 283 return MapSystemError(connect_os_error_); | 283 return MapSystemError(connect_os_error_); |
| 284 | 284 |
| 285 if (bind_address_.get()) { | 285 if (bind_address_.get()) { |
| 286 SockaddrStorage storage; | 286 SockaddrStorage storage; |
| 287 if (!bind_address_->ToSockAddr(storage.addr, &storage.addr_len)) | 287 if (!bind_address_->ToSockAddr(storage.addr, &storage.addr_len)) |
| 288 return ERR_INVALID_ARGUMENT; | 288 return ERR_INVALID_ARGUMENT; |
| 289 if (HANDLE_EINTR(bind(socket_, storage.addr, storage.addr_len))) | 289 if (HANDLE_EINTR(bind(socket_, storage.addr, storage.addr_len))) |
| 290 return MapSystemError(errno); | 290 return MapSystemError(errno); |
| 291 } | 291 } |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 783 |
| 784 NextProto TCPClientSocketLibevent::GetNegotiatedProtocol() const { | 784 NextProto TCPClientSocketLibevent::GetNegotiatedProtocol() const { |
| 785 return kProtoUnknown; | 785 return kProtoUnknown; |
| 786 } | 786 } |
| 787 | 787 |
| 788 bool TCPClientSocketLibevent::GetSSLInfo(SSLInfo* ssl_info) { | 788 bool TCPClientSocketLibevent::GetSSLInfo(SSLInfo* ssl_info) { |
| 789 return false; | 789 return false; |
| 790 } | 790 } |
| 791 | 791 |
| 792 } // namespace net | 792 } // namespace net |
| OLD | NEW |