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
3 // found in the LICENSE file.
5 #ifndef NET_SOCKET_SERVER_SOCKET_H_
6 #define NET_SOCKET_SERVER_SOCKET_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/completion_callback.h"
13 #include "net/base/net_export.h"
20 class NET_EXPORT ServerSocket
{
23 virtual ~ServerSocket();
25 // Binds the socket and starts listening. Destroys the socket to stop
27 virtual int Listen(const IPEndPoint
& address
, int backlog
) = 0;
29 // Binds the socket with address and port, and starts listening. It expects
30 // a valid IPv4 or IPv6 address. Otherwise, it returns ERR_ADDRESS_INVALID.
31 // Subclasses may override this function if |address_string| is in a different
32 // format, for example, unix domain socket path.
33 virtual int ListenWithAddressAndPort(const std::string
& address_string
,
37 // Gets current address the socket is bound to.
38 virtual int GetLocalAddress(IPEndPoint
* address
) const = 0;
40 // Accepts connection. Callback is called when new connection is
42 virtual int Accept(scoped_ptr
<StreamSocket
>* socket
,
43 const CompletionCallback
& callback
) = 0;
46 DISALLOW_COPY_AND_ASSIGN(ServerSocket
);
51 #endif // NET_SOCKET_SERVER_SOCKET_H_