7 #include "ppapi/c/pp_errors.h"
16 template <>
const char* interface_name<PPB_TCPSocket_1_0>() {
17 return PPB_TCPSOCKET_INTERFACE_1_0;
20 template <>
const char* interface_name<PPB_TCPSocket_1_1>() {
21 return PPB_TCPSOCKET_INTERFACE_1_1;
24 template <>
const char* interface_name<PPB_TCPSocket_1_2>() {
25 return PPB_TCPSOCKET_INTERFACE_1_2;
34 if (has_interface<PPB_TCPSocket_1_2>()) {
37 }
else if (has_interface<PPB_TCPSocket_1_1>()) {
40 }
else if (has_interface<PPB_TCPSocket_1_0>()) {
63 return has_interface<PPB_TCPSocket_1_2>() ||
64 has_interface<PPB_TCPSocket_1_1>() ||
65 has_interface<PPB_TCPSocket_1_0>();
70 if (has_interface<PPB_TCPSocket_1_2>()) {
71 return get_interface<PPB_TCPSocket_1_2>()->
Bind(
74 if (has_interface<PPB_TCPSocket_1_1>()) {
75 return get_interface<PPB_TCPSocket_1_1>()->
Bind(
78 return callback.
MayForce(PP_ERROR_NOINTERFACE);
83 if (has_interface<PPB_TCPSocket_1_2>()) {
84 return get_interface<PPB_TCPSocket_1_2>()->
Connect(
87 if (has_interface<PPB_TCPSocket_1_1>()) {
88 return get_interface<PPB_TCPSocket_1_1>()->
Connect(
91 if (has_interface<PPB_TCPSocket_1_0>()) {
92 return get_interface<PPB_TCPSocket_1_0>()->
Connect(
95 return callback.
MayForce(PP_ERROR_NOINTERFACE);
99 if (has_interface<PPB_TCPSocket_1_2>()) {
104 if (has_interface<PPB_TCPSocket_1_1>()) {
109 if (has_interface<PPB_TCPSocket_1_0>()) {
118 if (has_interface<PPB_TCPSocket_1_2>()) {
123 if (has_interface<PPB_TCPSocket_1_1>()) {
128 if (has_interface<PPB_TCPSocket_1_0>()) {
139 if (has_interface<PPB_TCPSocket_1_2>()) {
140 return get_interface<PPB_TCPSocket_1_2>()->
Read(
144 if (has_interface<PPB_TCPSocket_1_1>()) {
145 return get_interface<PPB_TCPSocket_1_1>()->
Read(
149 if (has_interface<PPB_TCPSocket_1_0>()) {
150 return get_interface<PPB_TCPSocket_1_0>()->
Read(
154 return callback.
MayForce(PP_ERROR_NOINTERFACE);
160 if (has_interface<PPB_TCPSocket_1_2>()) {
161 return get_interface<PPB_TCPSocket_1_2>()->
Write(
165 if (has_interface<PPB_TCPSocket_1_1>()) {
166 return get_interface<PPB_TCPSocket_1_1>()->
Write(
170 if (has_interface<PPB_TCPSocket_1_0>()) {
171 return get_interface<PPB_TCPSocket_1_0>()->
Write(
175 return callback.
MayForce(PP_ERROR_NOINTERFACE);
180 if (has_interface<PPB_TCPSocket_1_2>()) {
181 return get_interface<PPB_TCPSocket_1_2>()->
Listen(
184 if (has_interface<PPB_TCPSocket_1_1>()) {
185 return get_interface<PPB_TCPSocket_1_1>()->
Listen(
188 return callback.
MayForce(PP_ERROR_NOINTERFACE);
193 if (has_interface<PPB_TCPSocket_1_2>()) {
194 return get_interface<PPB_TCPSocket_1_2>()->
Accept(
197 if (has_interface<PPB_TCPSocket_1_1>()) {
198 return get_interface<PPB_TCPSocket_1_1>()->
Accept(
201 return callback.
MayForce(PP_ERROR_NOINTERFACE);
205 if (has_interface<PPB_TCPSocket_1_2>()) {
207 }
else if (has_interface<PPB_TCPSocket_1_1>()) {
209 }
else if (has_interface<PPB_TCPSocket_1_0>()) {
217 if (has_interface<PPB_TCPSocket_1_2>()) {
218 return get_interface<PPB_TCPSocket_1_2>()->
SetOption(
221 if (has_interface<PPB_TCPSocket_1_1>()) {
222 return get_interface<PPB_TCPSocket_1_1>()->
SetOption(
225 if (has_interface<PPB_TCPSocket_1_0>()) {
226 return get_interface<PPB_TCPSocket_1_0>()->
SetOption(
229 return callback.
MayForce(PP_ERROR_NOINTERFACE);
void PassRefFromConstructor(PP_Resource resource)
int32_t Listen(int32_t backlog, const CompletionCallback &callback)
int32_t SetOption(PP_TCPSocket_Option name, const Var &value, const CompletionCallback &callback)
NetAddress GetLocalAddress() const
int32_t Bind(const NetAddress &addr, const CompletionCallback &callback)
APIArgType output() const
int32_t Accept(const CompletionCallbackWithOutput< TCPSocket > &callback)
int32_t Read(char *buffer, int32_t bytes_to_read, const CompletionCallback &callback)
static bool IsAvailable()
int32_t MayForce(int32_t result) const
const PP_CompletionCallback & pp_completion_callback() const
int32_t Connect(const NetAddress &addr, const CompletionCallback &callback)
The NetAddress class represents a network address.
const PP_Var & pp_var() const
TCPSocket & operator=(const TCPSocket &other)
PP_Resource pp_resource() const
int32_t Write(const char *buffer, int32_t bytes_to_write, const CompletionCallback &callback)
NetAddress GetRemoteAddress() const
virtual ~TCPSocket()
The destructor.
A generic type used for passing data types between the module and the page.
PP_Instance pp_instance() const
A reference counted module resource.
Resource & operator=(const Resource &other)