#include <ppb_udp_socket.h>
|
PP_Resource(* | Create )(PP_Instance instance) |
|
PP_Bool(* | IsUDPSocket )(PP_Resource resource) |
|
int32_t(* | Bind )(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback) |
|
PP_Resource(* | GetBoundAddress )(PP_Resource udp_socket) |
|
int32_t(* | RecvFrom )(PP_Resource udp_socket, char *buffer, int32_t num_bytes, PP_Resource *addr, struct PP_CompletionCallback callback) |
|
int32_t(* | SendTo )(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback) |
|
void(* | Close )(PP_Resource udp_socket) |
|
int32_t(* | SetOption )(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback) |
|
int32_t(* | JoinGroup )(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback) |
|
int32_t(* | LeaveGroup )(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback) |
|
The PPB_UDPSocket
interface provides UDP socket operations.
Permissions: Apps permission socket
with subrule udp-bind
is required for Bind()
; subrule udp-send-to
is required for SendTo()
. For more details about network communication permissions, please see: http://developer.chrome.com/apps/app_network.html
Binds the socket to the given address.
- Parameters
-
[in] | udp_socket | A PP_Resource corresponding to a UDP socket. |
[in] | addr | A PPB_NetAddress resource. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
- Returns
- An int32_t containing an error code from
pp_errors.h
. PP_ERROR_NOACCESS
will be returned if the caller doesn't have required permissions. PP_ERROR_ADDRESS_IN_USE
will be returned if the address is already in use.
void(* PPB_UDPSocket_1_2::Close)(PP_Resource udp_socket) |
Cancels all pending reads and writes, and closes the socket. Any pending callbacks will still run, reporting PP_ERROR_ABORTED
if pending IO was interrupted. After a call to this method, no output parameters passed into previous RecvFrom()
calls will be accessed. It is not valid to call Bind()
again.
The socket is implicitly closed if it is destroyed, so you are not required to call this method.
- Parameters
-
[in] | udp_socket | A PP_Resource corresponding to a UDP socket. |
Creates a UDP socket resource.
- Parameters
-
[in] | instance | A PP_Instance identifying one instance of a module. |
- Returns
- A
PP_Resource
corresponding to a UDP socket or 0 on failure.
Gets the address that the socket is bound to. The socket must be bound.
- Parameters
-
[in] | udp_socket | A PP_Resource corresponding to a UDP socket. |
- Returns
- A
PPB_NetAddress
resource on success or 0 on failure.
Determines if a given resource is a UDP socket.
- Parameters
-
[in] | resource | A PP_Resource to check. |
- Returns
PP_TRUE
if the input is a PPB_UDPSocket
resource; PP_FALSE
otherwise.
Joins the multicast group with address specified by group
parameter, which is expected to be a PPB_NetAddress
object.
- Parameters
-
[in] | udp_socket | A PP_Resource corresponding to a UDP socket. |
[in] | group | A PP_Resource corresponding to the network address of the multicast group. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
- Returns
- An int32_t containing an error code from
pp_errors.h
.
Leaves the multicast group with address specified by group
parameter, which is expected to be a PPB_NetAddress
object.
- Parameters
-
[in] | udp_socket | A PP_Resource corresponding to a UDP socket. |
[in] | group | A PP_Resource corresponding to the network address of the multicast group. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
- Returns
- An int32_t containing an error code from
pp_errors.h
.
Receives data from the socket and stores the source address. The socket must be bound.
- Parameters
-
[in] | udp_socket | A PP_Resource corresponding to a UDP socket. |
[out] | buffer | The buffer to store the received data on success. It must be at least as large as num_bytes . |
[in] | num_bytes | The number of bytes to receive. |
[out] | addr | A PPB_NetAddress resource to store the source address on success. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
- Returns
- A non-negative number on success to indicate how many bytes have been received; otherwise, an error code from
pp_errors.h
.
Sends data to a specific destination. The socket must be bound.
- Parameters
-
[in] | udp_socket | A PP_Resource corresponding to a UDP socket. |
[in] | buffer | The buffer containing the data to send. |
[in] | num_bytes | The number of bytes to send. |
[in] | addr | A PPB_NetAddress resource holding the destination address. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
- Returns
- A non-negative number on success to indicate how many bytes have been sent; otherwise, an error code from
pp_errors.h
. PP_ERROR_NOACCESS
will be returned if the caller doesn't have required permissions. PP_ERROR_INPROGRESS
will be returned if the socket is busy sending. The caller should wait until a pending send completes before retrying.
Sets a socket option on the UDP socket. Please see the PP_UDPSocket_Option
description for option names, value types and allowed values.
- Parameters
-
[in] | udp_socket | A PP_Resource corresponding to a UDP socket. |
[in] | name | The option to set. |
[in] | value | The option value to set. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
- Returns
- An int32_t containing an error code from
pp_errors.h
.
The documentation for this struct was generated from the following file: