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/stream_listen_socket.h" | 5 #include "net/socket/stream_listen_socket.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 // winsock2.h must be included first in order to ensure it is included before | 8 // winsock2.h must be included first in order to ensure it is included before |
9 // windows.h. | 9 // windows.h. |
10 #include <winsock2.h> | 10 #include <winsock2.h> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 SockaddrStorage storage; | 89 SockaddrStorage storage; |
90 if (getsockname(socket_, storage.addr, &storage.addr_len)) { | 90 if (getsockname(socket_, storage.addr, &storage.addr_len)) { |
91 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
92 int err = WSAGetLastError(); | 92 int err = WSAGetLastError(); |
93 #else | 93 #else |
94 int err = errno; | 94 int err = errno; |
95 #endif | 95 #endif |
96 return MapSystemError(err); | 96 return MapSystemError(err); |
97 } | 97 } |
98 if (!address->FromSockAddr(storage.addr, storage.addr_len)) | 98 if (!address->FromSockAddr(storage.addr, storage.addr_len)) |
99 return ERR_FAILED; | 99 return ERR_ADDRESS_INVALID; |
100 return OK; | 100 return OK; |
101 } | 101 } |
102 | 102 |
103 SocketDescriptor StreamListenSocket::AcceptSocket() { | 103 SocketDescriptor StreamListenSocket::AcceptSocket() { |
104 SocketDescriptor conn = HANDLE_EINTR(accept(socket_, NULL, NULL)); | 104 SocketDescriptor conn = HANDLE_EINTR(accept(socket_, NULL, NULL)); |
105 if (conn == kInvalidSocket) | 105 if (conn == kInvalidSocket) |
106 LOG(ERROR) << "Error accepting connection."; | 106 LOG(ERROR) << "Error accepting connection."; |
107 else | 107 else |
108 SetNonBlocking(conn); | 108 SetNonBlocking(conn); |
109 return conn; | 109 return conn; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 void StreamListenSocket::ResumeReads() { | 298 void StreamListenSocket::ResumeReads() { |
299 DCHECK(reads_paused_); | 299 DCHECK(reads_paused_); |
300 reads_paused_ = false; | 300 reads_paused_ = false; |
301 if (has_pending_reads_) { | 301 if (has_pending_reads_) { |
302 has_pending_reads_ = false; | 302 has_pending_reads_ = false; |
303 Read(); | 303 Read(); |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 } // namespace net | 307 } // namespace net |
OLD | NEW |