OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ | 5 #ifndef NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ |
6 #define NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ | 6 #define NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 TCPServerSocketLibevent(net::NetLog* net_log, | 24 TCPServerSocketLibevent(net::NetLog* net_log, |
25 const net::NetLog::Source& source); | 25 const net::NetLog::Source& source); |
26 virtual ~TCPServerSocketLibevent(); | 26 virtual ~TCPServerSocketLibevent(); |
27 | 27 |
28 // net::ServerSocket implementation. | 28 // net::ServerSocket implementation. |
29 virtual int Listen(const net::IPEndPoint& address, int backlog) OVERRIDE; | 29 virtual int Listen(const net::IPEndPoint& address, int backlog) OVERRIDE; |
30 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; | 30 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; |
31 virtual int Accept(scoped_ptr<StreamSocket>* socket, | 31 virtual int Accept(scoped_ptr<StreamSocket>* socket, |
32 const CompletionCallback& callback) OVERRIDE; | 32 const CompletionCallback& callback) OVERRIDE; |
33 | 33 |
34 // Sets corresponding flags to allow the socket to share the local address to | |
wtc
2012/09/13 18:31:55
Please make the following changes to tcp_server_so
justinlin
2012/09/14 03:54:40
Done. Also moved the comment to interface.
| |
35 // which the socket will be bound with other processes. Should be called | |
36 // before Bind(). | |
37 void AllowAddressReuse(); | |
38 | |
34 // MessageLoopForIO::Watcher implementation. | 39 // MessageLoopForIO::Watcher implementation. |
35 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 40 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
36 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 41 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
37 | 42 |
38 private: | 43 private: |
44 int SetSocketOptions(); | |
39 int AcceptInternal(scoped_ptr<StreamSocket>* socket); | 45 int AcceptInternal(scoped_ptr<StreamSocket>* socket); |
40 void Close(); | 46 void Close(); |
41 | 47 |
42 int socket_; | 48 int socket_; |
43 | 49 |
44 MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_; | 50 MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_; |
45 | 51 |
46 scoped_ptr<StreamSocket>* accept_socket_; | 52 scoped_ptr<StreamSocket>* accept_socket_; |
47 CompletionCallback accept_callback_; | 53 CompletionCallback accept_callback_; |
48 | 54 |
55 bool reuse_address_; | |
56 | |
49 BoundNetLog net_log_; | 57 BoundNetLog net_log_; |
50 }; | 58 }; |
51 | 59 |
52 } // namespace net | 60 } // namespace net |
53 | 61 |
54 #endif // NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ | 62 #endif // NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ |
OLD | NEW |