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_libevent.h" | 5 #include "net/socket/tcp_server_socket_libevent.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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 DCHECK_EQ(socket_, kInvalidSocket); | 52 DCHECK_EQ(socket_, kInvalidSocket); |
53 | 53 |
54 reuse_address_ = true; | 54 reuse_address_ = true; |
55 } | 55 } |
56 | 56 |
57 int TCPServerSocketLibevent::Listen(const IPEndPoint& address, int backlog) { | 57 int TCPServerSocketLibevent::Listen(const IPEndPoint& address, int backlog) { |
58 DCHECK(CalledOnValidThread()); | 58 DCHECK(CalledOnValidThread()); |
59 DCHECK_GT(backlog, 0); | 59 DCHECK_GT(backlog, 0); |
60 DCHECK_EQ(socket_, kInvalidSocket); | 60 DCHECK_EQ(socket_, kInvalidSocket); |
61 | 61 |
62 socket_ = socket(address.GetFamily(), SOCK_STREAM, IPPROTO_TCP); | 62 socket_ = socket(address.GetSockAddrFamily(), SOCK_STREAM, IPPROTO_TCP); |
63 if (socket_ < 0) { | 63 if (socket_ < 0) { |
64 PLOG(ERROR) << "socket() returned an error"; | 64 PLOG(ERROR) << "socket() returned an error"; |
65 return MapSystemError(errno); | 65 return MapSystemError(errno); |
66 } | 66 } |
67 | 67 |
68 if (SetNonBlocking(socket_)) { | 68 if (SetNonBlocking(socket_)) { |
69 int result = MapSystemError(errno); | 69 int result = MapSystemError(errno); |
70 Close(); | 70 Close(); |
71 return result; | 71 return result; |
72 } | 72 } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 accept_callback_.Reset(); | 207 accept_callback_.Reset(); |
208 callback.Run(result); | 208 callback.Run(result); |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 void TCPServerSocketLibevent::OnFileCanWriteWithoutBlocking(int fd) { | 212 void TCPServerSocketLibevent::OnFileCanWriteWithoutBlocking(int fd) { |
213 NOTREACHED(); | 213 NOTREACHED(); |
214 } | 214 } |
215 | 215 |
216 } // namespace net | 216 } // namespace net |
OLD | NEW |