BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

activesock.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJ_ASYNCSOCK_H__
20#define __PJ_ASYNCSOCK_H__
21
27#include <pj/ioqueue.h>
28#include <pj/sock.h>
29
30
32
51
55typedef struct pj_activesock_cb
56{
84 void *data,
85 pj_size_t size,
86 pj_status_t status,
87 pj_size_t *remainder);
109 void *data,
110 pj_size_t size,
111 const pj_sockaddr_t *src_addr,
112 int addr_len,
113 pj_status_t status);
114
130 pj_ssize_t sent);
131
148 pj_sock_t newsock,
149 const pj_sockaddr_t *src_addr,
150 int src_addr_len);
151
171 pj_sock_t newsock,
172 const pj_sockaddr_t *src_addr,
173 int src_addr_len,
174 pj_status_t status);
175
189 pj_status_t status);
190
192
193
198typedef struct pj_activesock_cfg
199{
204
217 unsigned async_cnt;
218
233
248
250
251
258
259
283 pj_sock_t sock,
284 int sock_type,
285 const pj_activesock_cfg *opt,
286 pj_ioqueue_t *ioqueue,
287 const pj_activesock_cb *cb,
288 void *user_data,
289 pj_activesock_t **p_asock);
290
315 const pj_sockaddr *addr,
316 const pj_activesock_cfg *opt,
317 pj_ioqueue_t *ioqueue,
318 const pj_activesock_cb *cb,
319 void *user_data,
320 pj_activesock_t **p_asock,
321 pj_sockaddr *bound_addr);
322
333
334#if (defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
335 PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0) || \
336 defined(DOXYGEN)
350PJ_DECL(void) pj_activesock_set_iphone_os_bg(pj_activesock_t *asock,
351 int val);
352
366PJ_DECL(void) pj_activesock_enable_iphone_os_bg(pj_bool_t val);
367#endif
368
382 void *user_data);
383
393
394
418 pj_pool_t *pool,
419 unsigned buff_size,
420 pj_uint32_t flags);
421
437 pj_pool_t *pool,
438 unsigned buff_size,
439 void *readbuf[],
440 pj_uint32_t flags);
441
456 pj_pool_t *pool,
457 unsigned buff_size,
458 pj_uint32_t flags);
459
475 pj_pool_t *pool,
476 unsigned buff_size,
477 void *readbuf[],
478 pj_uint32_t flags);
479
502 const void *data,
503 pj_ssize_t *size,
504 unsigned flags);
505
529 const void *data,
530 pj_ssize_t *size,
531 unsigned flags,
532 const pj_sockaddr_t *addr,
533 int addr_len);
534
535#if PJ_HAS_TCP
556 pj_pool_t *pool);
557
576 pj_pool_t *pool,
577 const pj_sockaddr_t *remaddr,
578 int addr_len);
579
580
581#endif /* PJ_HAS_TCP */
582
588
589#endif /* __PJ_ASYNCSOCK_H__ */
590
struct pj_activesock_t pj_activesock_t
Definition: activesock.h:50
pj_status_t pj_activesock_set_user_data(pj_activesock_t *asock, void *user_data)
pj_status_t pj_activesock_sendto(pj_activesock_t *asock, pj_ioqueue_op_key_t *send_key, const void *data, pj_ssize_t *size, unsigned flags, const pj_sockaddr_t *addr, int addr_len)
pj_status_t pj_activesock_start_recvfrom(pj_activesock_t *asock, pj_pool_t *pool, unsigned buff_size, pj_uint32_t flags)
void pj_activesock_cfg_default(pj_activesock_cfg *cfg)
pj_status_t pj_activesock_start_connect(pj_activesock_t *asock, pj_pool_t *pool, const pj_sockaddr_t *remaddr, int addr_len)
pj_status_t pj_activesock_send(pj_activesock_t *asock, pj_ioqueue_op_key_t *send_key, const void *data, pj_ssize_t *size, unsigned flags)
pj_status_t pj_activesock_create(pj_pool_t *pool, pj_sock_t sock, int sock_type, const pj_activesock_cfg *opt, pj_ioqueue_t *ioqueue, const pj_activesock_cb *cb, void *user_data, pj_activesock_t **p_asock)
void * pj_activesock_get_user_data(pj_activesock_t *asock)
pj_status_t pj_activesock_close(pj_activesock_t *asock)
pj_status_t pj_activesock_start_read2(pj_activesock_t *asock, pj_pool_t *pool, unsigned buff_size, void *readbuf[], pj_uint32_t flags)
pj_status_t pj_activesock_start_recvfrom2(pj_activesock_t *asock, pj_pool_t *pool, unsigned buff_size, void *readbuf[], pj_uint32_t flags)
pj_status_t pj_activesock_start_accept(pj_activesock_t *asock, pj_pool_t *pool)
pj_status_t pj_activesock_start_read(pj_activesock_t *asock, pj_pool_t *pool, unsigned buff_size, pj_uint32_t flags)
pj_status_t pj_activesock_create_udp(pj_pool_t *pool, const pj_sockaddr *addr, const pj_activesock_cfg *opt, pj_ioqueue_t *ioqueue, const pj_activesock_cb *cb, void *user_data, pj_activesock_t **p_asock, pj_sockaddr *bound_addr)
long pj_ssize_t
Definition: types.h:64
int pj_bool_t
Definition: types.h:71
struct pj_ioqueue_t pj_ioqueue_t
Definition: types.h:210
long pj_sock_t
Definition: types.h:263
size_t pj_size_t
Definition: types.h:58
void pj_sockaddr_t
Definition: types.h:267
int pj_status_t
Definition: types.h:68
struct pj_grp_lock_t pj_grp_lock_t
Definition: types.h:242
unsigned int pj_uint32_t
Definition: types.h:43
#define PJ_BEGIN_DECL
Definition: config.h:1284
#define PJ_END_DECL
Definition: config.h:1285
I/O Dispatching Mechanism.
Socket Abstraction.
Definition: activesock.h:56
pj_bool_t(* on_connect_complete)(pj_activesock_t *asock, pj_status_t status)
Definition: activesock.h:188
pj_bool_t(* on_data_recvfrom)(pj_activesock_t *asock, void *data, pj_size_t size, const pj_sockaddr_t *src_addr, int addr_len, pj_status_t status)
Definition: activesock.h:108
pj_bool_t(* on_accept_complete2)(pj_activesock_t *asock, pj_sock_t newsock, const pj_sockaddr_t *src_addr, int src_addr_len, pj_status_t status)
Definition: activesock.h:170
pj_bool_t(* on_data_sent)(pj_activesock_t *asock, pj_ioqueue_op_key_t *send_key, pj_ssize_t sent)
Definition: activesock.h:128
pj_bool_t(* on_data_read)(pj_activesock_t *asock, void *data, pj_size_t size, pj_status_t status, pj_size_t *remainder)
Definition: activesock.h:83
pj_bool_t(* on_accept_complete)(pj_activesock_t *asock, pj_sock_t newsock, const pj_sockaddr_t *src_addr, int src_addr_len)
Definition: activesock.h:147
Definition: activesock.h:199
unsigned async_cnt
Definition: activesock.h:217
pj_grp_lock_t * grp_lock
Definition: activesock.h:203
pj_bool_t whole_data
Definition: activesock.h:247
int concurrency
Definition: activesock.h:232
Definition: ioqueue.h:208
Definition: pool.h:310
Definition: activesock.c:270
Definition: sock.h:633

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.