Pepper_56_C_interfaces
Pepper_56_C_interfaces
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
PPB_UDPSocket_1_2 Struct Reference

#include <ppb_udp_socket.h>

Public Attributes

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)
 

Detailed Description

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

Member Data Documentation

int32_t(* PPB_UDPSocket_1_2::Bind)(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback)

Binds the socket to the given address.

Parameters
[in]udp_socketA PP_Resource corresponding to a UDP socket.
[in]addrA PPB_NetAddress resource.
[in]callbackA 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_socketA PP_Resource corresponding to a UDP socket.
PP_Resource(* PPB_UDPSocket_1_2::Create)(PP_Instance instance)

Creates a UDP socket resource.

Parameters
[in]instanceA PP_Instance identifying one instance of a module.
Returns
A PP_Resource corresponding to a UDP socket or 0 on failure.
PP_Resource(* PPB_UDPSocket_1_2::GetBoundAddress)(PP_Resource udp_socket)

Gets the address that the socket is bound to. The socket must be bound.

Parameters
[in]udp_socketA PP_Resource corresponding to a UDP socket.
Returns
A PPB_NetAddress resource on success or 0 on failure.
PP_Bool(* PPB_UDPSocket_1_2::IsUDPSocket)(PP_Resource resource)

Determines if a given resource is a UDP socket.

Parameters
[in]resourceA PP_Resource to check.
Returns
PP_TRUE if the input is a PPB_UDPSocket resource; PP_FALSE otherwise.
int32_t(* PPB_UDPSocket_1_2::JoinGroup)(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback)

Joins the multicast group with address specified by group parameter, which is expected to be a PPB_NetAddress object.

Parameters
[in]udp_socketA PP_Resource corresponding to a UDP socket.
[in]groupA PP_Resource corresponding to the network address of the multicast group.
[in]callbackA PP_CompletionCallback to be called upon completion.
Returns
An int32_t containing an error code from pp_errors.h.
int32_t(* PPB_UDPSocket_1_2::LeaveGroup)(PP_Resource udp_socket, PP_Resource group, struct PP_CompletionCallback callback)

Leaves the multicast group with address specified by group parameter, which is expected to be a PPB_NetAddress object.

Parameters
[in]udp_socketA PP_Resource corresponding to a UDP socket.
[in]groupA PP_Resource corresponding to the network address of the multicast group.
[in]callbackA PP_CompletionCallback to be called upon completion.
Returns
An int32_t containing an error code from pp_errors.h.
int32_t(* PPB_UDPSocket_1_2::RecvFrom)(PP_Resource udp_socket, char *buffer, int32_t num_bytes, PP_Resource *addr, struct PP_CompletionCallback callback)

Receives data from the socket and stores the source address. The socket must be bound.

Parameters
[in]udp_socketA PP_Resource corresponding to a UDP socket.
[out]bufferThe buffer to store the received data on success. It must be at least as large as num_bytes.
[in]num_bytesThe number of bytes to receive.
[out]addrA PPB_NetAddress resource to store the source address on success.
[in]callbackA 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.
int32_t(* PPB_UDPSocket_1_2::SendTo)(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback)

Sends data to a specific destination. The socket must be bound.

Parameters
[in]udp_socketA PP_Resource corresponding to a UDP socket.
[in]bufferThe buffer containing the data to send.
[in]num_bytesThe number of bytes to send.
[in]addrA PPB_NetAddress resource holding the destination address.
[in]callbackA 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.
int32_t(* PPB_UDPSocket_1_2::SetOption)(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback)

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_socketA PP_Resource corresponding to a UDP socket.
[in]nameThe option to set.
[in]valueThe option value to set.
[in]callbackA 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: