Pepper_31_C_interfaces
|
#include <ppb_tcp_socket.h>
Public Attributes | |
PP_Resource(* | Create )(PP_Instance instance) |
PP_Bool(* | IsTCPSocket )(PP_Resource resource) |
int32_t(* | Bind )(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback) |
int32_t(* | Connect )(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback) |
PP_Resource(* | GetLocalAddress )(PP_Resource tcp_socket) |
PP_Resource(* | GetRemoteAddress )(PP_Resource tcp_socket) |
int32_t(* | Read )(PP_Resource tcp_socket, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback) |
int32_t(* | Write )(PP_Resource tcp_socket, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback) |
int32_t(* | Listen )(PP_Resource tcp_socket, int32_t backlog, struct PP_CompletionCallback callback) |
int32_t(* | Accept )(PP_Resource tcp_socket, PP_Resource *accepted_tcp_socket, struct PP_CompletionCallback callback) |
void(* | Close )(PP_Resource tcp_socket) |
int32_t(* | SetOption )(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback) |
The PPB_TCPSocket
interface provides TCP socket operations.
Permissions: Apps permission socket
with subrule tcp-connect
is required for Connect()
; subrule tcp-listen
is required for Listen()
. For more details about network communication permissions, please see: http://developer.chrome.com/apps/app_network.html
Definition at line 82 of file ppb_tcp_socket.h.
int32_t(* PPB_TCPSocket_1_1::Accept)(PP_Resource tcp_socket, PP_Resource *accepted_tcp_socket, struct PP_CompletionCallback callback) |
Accepts a connection. The socket must be listening.
[in] | tcp_socket | A PP_Resource corresponding to a TCP socket. |
[out] | accepted_tcp_socket | Stores the accepted TCP socket on success. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
pp_errors.h
, including (but not limited to):PP_ERROR_CONNECTION_ABORTED
: A connection has been aborted. Definition at line 238 of file ppb_tcp_socket.h.
int32_t(* PPB_TCPSocket_1_1::Bind)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback) |
Binds the socket to the given address. The socket must not be bound.
[in] | tcp_socket | A PP_Resource corresponding to a TCP socket. |
[in] | addr | A PPB_NetAddress resource. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
pp_errors.h
, including (but not limited to):PP_ERROR_ADDRESS_IN_USE
: the address is already in use.PP_ERROR_ADDRESS_INVALID
: the address is invalid. Definition at line 116 of file ppb_tcp_socket.h.
void(* PPB_TCPSocket_1_1::Close)(PP_Resource tcp_socket) |
Cancels all pending operations 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 buffer pointers passed into previous Read()
or Accept()
calls will be accessed. It is not valid to call Connect()
or Listen()
again.
The socket is implicitly closed if it is destroyed, so you are not required to call this method.
[in] | tcp_socket | A PP_Resource corresponding to a TCP socket. |
Definition at line 255 of file ppb_tcp_socket.h.
int32_t(* PPB_TCPSocket_1_1::Connect)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback) |
Connects the socket to the given address. The socket must not be listening. Binding the socket beforehand is optional.
[in] | tcp_socket | A PP_Resource corresponding to a TCP socket. |
[in] | addr | A PPB_NetAddress resource. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
pp_errors.h
, including (but not limited to):PP_ERROR_NOACCESS
: the caller doesn't have required permissions.PP_ERROR_ADDRESS_UNREACHABLE
: addr
is unreachable.PP_ERROR_CONNECTION_REFUSED
: the connection attempt was refused.PP_ERROR_CONNECTION_FAILED
: the connection attempt failed.PP_ERROR_CONNECTION_TIMEDOUT
: the connection attempt timed out.Since version 1.1, if the socket is listening/connected or has a pending listen/connect request, Connect()
will fail without starting a connection attempt; otherwise, any failure during the connection attempt will cause the socket to be closed.
Definition at line 146 of file ppb_tcp_socket.h.
PP_Resource(* PPB_TCPSocket_1_1::Create)(PP_Instance instance) |
Creates a TCP socket resource.
[in] | instance | A PP_Instance identifying one instance of a module. |
PP_Resource
corresponding to a TCP socket or 0 on failure. Definition at line 92 of file ppb_tcp_socket.h.
PP_Resource(* PPB_TCPSocket_1_1::GetLocalAddress)(PP_Resource tcp_socket) |
Gets the local address of the socket, if it is bound.
[in] | tcp_socket | A PP_Resource corresponding to a TCP socket. |
PPB_NetAddress
resource on success or 0 on failure. Definition at line 157 of file ppb_tcp_socket.h.
PP_Resource(* PPB_TCPSocket_1_1::GetRemoteAddress)(PP_Resource tcp_socket) |
Gets the remote address of the socket, if it is connected.
[in] | tcp_socket | A PP_Resource corresponding to a TCP socket. |
PPB_NetAddress
resource on success or 0 on failure. Definition at line 166 of file ppb_tcp_socket.h.
PP_Bool(* PPB_TCPSocket_1_1::IsTCPSocket)(PP_Resource resource) |
Determines if a given resource is a TCP socket.
[in] | resource | A PP_Resource to check. |
PP_TRUE
if the input is a PPB_TCPSocket
resource; PP_FALSE
otherwise. Definition at line 101 of file ppb_tcp_socket.h.
int32_t(* PPB_TCPSocket_1_1::Listen)(PP_Resource tcp_socket, int32_t backlog, struct PP_CompletionCallback callback) |
Starts listening. The socket must be bound and not connected.
[in] | tcp_socket | A PP_Resource corresponding to a TCP socket. |
[in] | backlog | A hint to determine the maximum length to which the queue of pending connections may grow. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
pp_errors.h
, including (but not limited to):PP_ERROR_NOACCESS
: the caller doesn't have required permissions.PP_ERROR_ADDRESS_IN_USE
: Another socket is already listening on the same port. Definition at line 222 of file ppb_tcp_socket.h.
int32_t(* PPB_TCPSocket_1_1::Read)(PP_Resource tcp_socket, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback) |
Reads data from the socket. The socket must be connected. It may perform a partial read.
[in] | tcp_socket | A PP_Resource corresponding to a TCP socket. |
[out] | buffer | The buffer to store the received data on success. It must be at least as large as bytes_to_read . |
[in] | bytes_to_read | The number of bytes to read. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
pp_errors.h
. Definition at line 183 of file ppb_tcp_socket.h.
int32_t(* PPB_TCPSocket_1_1::SetOption)(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback) |
Sets a socket option on the TCP socket. Please see the PP_TCPSocket_Option
description for option names, value types and allowed values.
[in] | tcp_socket | A PP_Resource corresponding to a TCP socket. |
[in] | name | The option to set. |
[in] | value | The option value to set. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
pp_errors.h
. Definition at line 270 of file ppb_tcp_socket.h.
int32_t(* PPB_TCPSocket_1_1::Write)(PP_Resource tcp_socket, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback) |
Writes data to the socket. The socket must be connected. It may perform a partial write.
[in] | tcp_socket | A PP_Resource corresponding to a TCP socket. |
[in] | buffer | The buffer containing the data to write. |
[in] | bytes_to_write | The number of bytes to write. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
pp_errors.h
. Definition at line 201 of file ppb_tcp_socket.h.