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_SERVER_SOCKET_H_ | 5 #ifndef NET_SOCKET_SERVER_SOCKET_H_ |
6 #define NET_SOCKET_SERVER_SOCKET_H_ | 6 #define NET_SOCKET_SERVER_SOCKET_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/ip_endpoint.h" | |
10 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
11 | 12 |
12 namespace net { | 13 namespace net { |
13 | 14 |
14 class IPEndPoint; | |
15 class StreamSocket; | 15 class StreamSocket; |
16 | 16 |
17 class NET_EXPORT ServerSocket { | 17 class NET_EXPORT ServerSocket { |
18 public: | 18 public: |
19 ServerSocket() { } | 19 ServerSocket(); |
20 virtual ~ServerSocket() { } | 20 virtual ~ServerSocket(); |
21 | 21 |
22 // Bind the socket and start listening. Destroy the socket to stop | 22 // Binds the socket and start listening. Destroy the socket to stop |
23 // listening. | 23 // listening. |
24 virtual int Listen(const net::IPEndPoint& address, int backlog) = 0; | 24 virtual int Listen(const net::IPEndPoint& address, int backlog) = 0; |
25 | 25 |
26 // Binds the socket with address and port, and start listening. It expects | |
27 // a vaild IPv4 or IPv6 address. Otherwise, it returns ERR_ADDRESS_INVALID. | |
28 // Subclasses may override this function if |ip_address| is not a valid IP | |
29 // address. | |
mmenke
2014/06/11 16:05:50
The last sentence is confusing - unclear what it's
byungchul
2014/06/20 08:22:32
Revised in the other CL, https://codereview.chromi
| |
30 virtual int ListenWithAddressAndPort(const std::string& ip_address, | |
31 int port, | |
32 int backlog); | |
33 | |
26 // Gets current address the socket is bound to. | 34 // Gets current address the socket is bound to. |
27 virtual int GetLocalAddress(IPEndPoint* address) const = 0; | 35 virtual int GetLocalAddress(IPEndPoint* address) const = 0; |
28 | 36 |
29 // Accept connection. Callback is called when new connection is | 37 // Accepts connection. Callback is called when new connection is |
30 // accepted. | 38 // accepted. |
31 virtual int Accept(scoped_ptr<StreamSocket>* socket, | 39 virtual int Accept(scoped_ptr<StreamSocket>* socket, |
32 const CompletionCallback& callback) = 0; | 40 const CompletionCallback& callback) = 0; |
33 | 41 |
34 private: | 42 private: |
35 DISALLOW_COPY_AND_ASSIGN(ServerSocket); | 43 DISALLOW_COPY_AND_ASSIGN(ServerSocket); |
36 }; | 44 }; |
37 | 45 |
38 } // namespace net | 46 } // namespace net |
39 | 47 |
40 #endif // NET_SOCKET_SERVER_SOCKET_H_ | 48 #endif // NET_SOCKET_SERVER_SOCKET_H_ |
OLD | NEW |