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 27 matching lines...) Expand all Loading... | |
38 DCHECK_EQ(socket_, INVALID_SOCKET); | 38 DCHECK_EQ(socket_, INVALID_SOCKET); |
39 DCHECK_EQ(socket_event_, WSA_INVALID_EVENT); | 39 DCHECK_EQ(socket_event_, WSA_INVALID_EVENT); |
40 | 40 |
41 socket_event_ = WSACreateEvent(); | 41 socket_event_ = WSACreateEvent(); |
42 if (socket_event_ == WSA_INVALID_EVENT) { | 42 if (socket_event_ == WSA_INVALID_EVENT) { |
43 PLOG(ERROR) << "WSACreateEvent()"; | 43 PLOG(ERROR) << "WSACreateEvent()"; |
44 return ERR_FAILED; | 44 return ERR_FAILED; |
45 } | 45 } |
46 | 46 |
47 socket_ = socket(address.GetSockAddrFamily(), SOCK_STREAM, IPPROTO_TCP); | 47 socket_ = socket(address.GetSockAddrFamily(), SOCK_STREAM, IPPROTO_TCP); |
48 if (socket_ < 0) { | 48 if (socket_ == INVALID_SOCKET) { |
wtc
2013/08/12 17:31:30
See the "Return value" section and example code in
| |
49 PLOG(ERROR) << "socket() returned an error"; | 49 PLOG(ERROR) << "socket() returned an error"; |
50 return MapSystemError(WSAGetLastError()); | 50 return MapSystemError(WSAGetLastError()); |
51 } | 51 } |
52 | 52 |
53 if (SetNonBlocking(socket_)) { | 53 if (SetNonBlocking(socket_)) { |
54 int result = MapSystemError(WSAGetLastError()); | 54 int result = MapSystemError(WSAGetLastError()); |
55 Close(); | 55 Close(); |
56 return result; | 56 return result; |
57 } | 57 } |
58 | 58 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 if (result != ERR_IO_PENDING) { | 208 if (result != ERR_IO_PENDING) { |
209 accept_socket_ = NULL; | 209 accept_socket_ = NULL; |
210 CompletionCallback callback = accept_callback_; | 210 CompletionCallback callback = accept_callback_; |
211 accept_callback_.Reset(); | 211 accept_callback_.Reset(); |
212 callback.Run(result); | 212 callback.Run(result); |
213 } | 213 } |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 } // namespace net | 217 } // namespace net |
OLD | NEW |