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_WIN_H_ | 5 #ifndef NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_ |
6 #define NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_ | 6 #define NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_ |
7 | 7 |
8 #include <winsock2.h> | 8 #include <winsock2.h> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 | 30 |
31 // net::ServerSocket implementation. | 31 // net::ServerSocket implementation. |
32 virtual int Listen(const net::IPEndPoint& address, int backlog); | 32 virtual int Listen(const net::IPEndPoint& address, int backlog); |
33 virtual int GetLocalAddress(IPEndPoint* address) const; | 33 virtual int GetLocalAddress(IPEndPoint* address) const; |
34 virtual int Accept(scoped_ptr<StreamSocket>* socket, | 34 virtual int Accept(scoped_ptr<StreamSocket>* socket, |
35 const CompletionCallback& callback); | 35 const CompletionCallback& callback); |
36 | 36 |
37 // base::ObjectWatcher::Delegate implementation. | 37 // base::ObjectWatcher::Delegate implementation. |
38 virtual void OnObjectSignaled(HANDLE object); | 38 virtual void OnObjectSignaled(HANDLE object); |
39 | 39 |
40 // Sets corresponding flags in |socket_options_| to allow the socket | |
41 // to share the local address to which the socket will be bound with | |
42 // other processes. Should be called before Bind(). | |
43 void AllowAddressReuse(); | |
44 | |
40 private: | 45 private: |
41 int AcceptInternal(scoped_ptr<StreamSocket>* socket); | 46 int AcceptInternal(scoped_ptr<StreamSocket>* socket); |
42 void Close(); | 47 void Close(); |
43 | 48 |
49 enum SocketOptions { | |
50 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, | |
51 } | |
Sergey Ulanov
2012/09/12 19:38:24
I think you are missing semicolon here
justinlin
2012/09/12 21:11:00
Ack
| |
52 | |
53 // Applies |socket_options_| to |socket_|. Should be called before | |
54 // Bind(). | |
55 int SetSocketOptions(); | |
56 | |
44 SOCKET socket_; | 57 SOCKET socket_; |
45 HANDLE socket_event_; | 58 HANDLE socket_event_; |
46 | 59 |
60 // Bitwise-or'd combination of SocketOptions. Specifies the set of | |
61 // options that should be applied to |socket_| before Bind(). | |
62 int socket_options_; | |
63 | |
47 base::win::ObjectWatcher accept_watcher_; | 64 base::win::ObjectWatcher accept_watcher_; |
48 | 65 |
49 scoped_ptr<StreamSocket>* accept_socket_; | 66 scoped_ptr<StreamSocket>* accept_socket_; |
50 CompletionCallback accept_callback_; | 67 CompletionCallback accept_callback_; |
51 | 68 |
52 BoundNetLog net_log_; | 69 BoundNetLog net_log_; |
53 }; | 70 }; |
54 | 71 |
55 } // namespace net | 72 } // namespace net |
56 | 73 |
57 #endif // NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_ | 74 #endif // NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_ |
OLD | NEW |