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
3 * found in the LICENSE file.
4 */
5
6/**
7 * This file defines the <code>PPB_TCPServerSocket_Private</code> interface.
8 */
9
10label Chrome {
11  M18 = 0.1,
12  M28 = 0.2
13};
14
15/**
16 * The <code>PPB_TCPServerSocket_Private</code> interface provides TCP
17 * server socket operations.
18 */
19interface PPB_TCPServerSocket_Private {
20  /**
21   * Allocates a TCP server socket resource.
22   */
23  PP_Resource Create([in] PP_Instance instance);
24
25  /**
26   * Determines if a given resource is TCP server socket.
27   */
28  PP_Bool IsTCPServerSocket([in] PP_Resource resource);
29
30  /**
31   * Binds |tcp_server_socket| to the address given by |addr| and
32   * starts listening.  The |backlog| argument defines the maximum
33   * length to which the queue of pending connections may
34   * grow. |callback| is invoked when |tcp_server_socket| is ready to
35   * accept incoming connections or in the case of failure. Returns
36   * PP_ERROR_NOSPACE if socket can't be initialized, or
37   * PP_ERROR_FAILED in the case of Listen failure. Otherwise, returns
38   * PP_OK.
39   */
40  int32_t Listen([in] PP_Resource tcp_server_socket,
41                 [in] PP_NetAddress_Private addr,
42                 [in] int32_t backlog,
43                 [in] PP_CompletionCallback callback);
44
45  /**
46   * Accepts single connection, creates instance of
47   * PPB_TCPSocket_Private and stores reference to it in
48   * |tcp_socket|. |callback| is invoked when connection is accepted
49   * or in the case of failure. This method can be called only after
50   * successful Listen call on |tcp_server_socket|.
51   */
52  int32_t Accept([in] PP_Resource tcp_server_socket,
53                 [out] PP_Resource tcp_socket,
54                 [in] PP_CompletionCallback callback);
55
56  /**
57   * Returns the current address to which the socket is bound, in the
58   * buffer pointed to by |addr|. This method can be called only after
59   * successful Listen() call and before StopListening() call.
60   */
61  [version=0.2]
62  int32_t GetLocalAddress([in] PP_Resource tcp_server_socket,
63                          [out] PP_NetAddress_Private addr);
64
65  /**
66   * Cancels all pending callbacks reporting PP_ERROR_ABORTED and
67   * closes the socket. Note: this method is implicitly called when
68   * server socket is destroyed.
69   */
70  void StopListening([in] PP_Resource tcp_server_socket);
71};
72