blob: 083c33d1991a31f8b41ffd978b3b2d2425f238cc [file] [log] [blame]
/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/**
* This file defines the <code>PPB_UDPSocket_Private</code> interface.
*/
label Chrome {
M17 = 0.2,
M19 = 0.3
};
interface PPB_UDPSocket_Private {
/**
* Creates a UDP socket resource.
*/
PP_Resource Create([in] PP_Instance instance_id);
/**
* Determines if a given resource is a UDP socket.
*/
PP_Bool IsUDPSocket([in] PP_Resource resource_id);
/* Creates a socket and binds to the address given by |addr|. */
int32_t Bind([in] PP_Resource udp_socket,
[in] PP_NetAddress_Private addr,
[in] PP_CompletionCallback callback);
/* Returns the address that the socket has bound to. A successful
* call to Bind must be called first. Returns PP_FALSE if Bind
* fails, or if Close has been called.
*/
[version=0.3]
PP_Bool GetBoundAddress([in] PP_Resource udp_socket,
[out] PP_NetAddress_Private addr);
/* Performs a non-blocking recvfrom call on socket.
* Bind must be called first. |callback| is invoked when recvfrom
* reads data. You must call GetRecvFromAddress to recover the
* address the data was retrieved from.
*/
int32_t RecvFrom([in] PP_Resource udp_socket,
[out] str_t buffer,
[in] int32_t num_bytes,
[in] PP_CompletionCallback callback);
/* Upon successful completion of RecvFrom, the address that the data
* was received from is stored in |addr|.
*/
PP_Bool GetRecvFromAddress([in] PP_Resource udp_socket,
[out] PP_NetAddress_Private addr);
/* Performs a non-blocking sendto call on the socket created and
* bound(has already called Bind). The callback |callback| is
* invoked when sendto completes.
*/
int32_t SendTo([in] PP_Resource udp_socket,
[in] str_t buffer,
[in] int32_t num_bytes,
[in] PP_NetAddress_Private addr,
[in] PP_CompletionCallback callback);
/* Cancels all pending reads and writes, and closes the socket. */
void Close([in] PP_Resource udp_socket);
};