| 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_server_socket_win.h" | 5 #include "net/socket/tcp_server_socket_win.h" |
| 6 | 6 |
| 7 #include <mstcpip.h> | 7 #include <mstcpip.h> |
| 8 | 8 |
| 9 #include "net/base/ip_endpoint.h" | 9 #include "net/base/ip_endpoint.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 DCHECK_GT(backlog, 0); | 46 DCHECK_GT(backlog, 0); |
| 47 DCHECK_EQ(socket_, INVALID_SOCKET); | 47 DCHECK_EQ(socket_, INVALID_SOCKET); |
| 48 DCHECK_EQ(socket_event_, WSA_INVALID_EVENT); | 48 DCHECK_EQ(socket_event_, WSA_INVALID_EVENT); |
| 49 | 49 |
| 50 socket_event_ = WSACreateEvent(); | 50 socket_event_ = WSACreateEvent(); |
| 51 if (socket_event_ == WSA_INVALID_EVENT) { | 51 if (socket_event_ == WSA_INVALID_EVENT) { |
| 52 PLOG(ERROR) << "WSACreateEvent()"; | 52 PLOG(ERROR) << "WSACreateEvent()"; |
| 53 return ERR_FAILED; | 53 return ERR_FAILED; |
| 54 } | 54 } |
| 55 | 55 |
| 56 socket_ = socket(address.GetFamily(), SOCK_STREAM, IPPROTO_TCP); | 56 socket_ = socket(address.GetSockAddrFamily(), SOCK_STREAM, IPPROTO_TCP); |
| 57 if (socket_ < 0) { | 57 if (socket_ < 0) { |
| 58 PLOG(ERROR) << "socket() returned an error"; | 58 PLOG(ERROR) << "socket() returned an error"; |
| 59 return MapSystemError(WSAGetLastError()); | 59 return MapSystemError(WSAGetLastError()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 if (SetNonBlocking(socket_)) { | 62 if (SetNonBlocking(socket_)) { |
| 63 int result = MapSystemError(WSAGetLastError()); | 63 int result = MapSystemError(WSAGetLastError()); |
| 64 Close(); | 64 Close(); |
| 65 return result; | 65 return result; |
| 66 } | 66 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if (result != ERR_IO_PENDING) { | 199 if (result != ERR_IO_PENDING) { |
| 200 accept_socket_ = NULL; | 200 accept_socket_ = NULL; |
| 201 CompletionCallback callback = accept_callback_; | 201 CompletionCallback callback = accept_callback_; |
| 202 accept_callback_.Reset(); | 202 accept_callback_.Reset(); |
| 203 callback.Run(result); | 203 callback.Run(result); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace net | 208 } // namespace net |
| OLD | NEW |