BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

activesock.h
Go to the documentation of this file.
1 /* $Id: activesock.h 4461 2013-04-05 03:02:19Z riza $ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 #ifndef __PJ_ASYNCSOCK_H__
21 #define __PJ_ASYNCSOCK_H__
22 
28 #include <pj/ioqueue.h>
29 #include <pj/sock.h>
30 
31 
33 
52 
56 typedef struct pj_activesock_cb
57 {
85  void *data,
86  pj_size_t size,
87  pj_status_t status,
88  pj_size_t *remainder);
110  void *data,
111  pj_size_t size,
112  const pj_sockaddr_t *src_addr,
113  int addr_len,
114  pj_status_t status);
115 
131  pj_ssize_t sent);
132 
149  pj_sock_t newsock,
150  const pj_sockaddr_t *src_addr,
151  int src_addr_len);
152 
172  pj_sock_t newsock,
173  const pj_sockaddr_t *src_addr,
174  int src_addr_len,
175  pj_status_t status);
176 
190  pj_status_t status);
191 
193 
194 
199 typedef struct pj_activesock_cfg
200 {
205 
218  unsigned async_cnt;
219 
234 
249 
251 
252 
258 PJ_DECL(void) pj_activesock_cfg_default(pj_activesock_cfg *cfg);
259 
260 
284  pj_sock_t sock,
285  int sock_type,
286  const pj_activesock_cfg *opt,
287  pj_ioqueue_t *ioqueue,
288  const pj_activesock_cb *cb,
289  void *user_data,
290  pj_activesock_t **p_asock);
291 
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)
337 
350 PJ_DECL(void) pj_activesock_set_iphone_os_bg(pj_activesock_t *asock,
351  int val);
352 
366 PJ_DECL(void) pj_activesock_enable_iphone_os_bg(pj_bool_t val);
367 #endif
368 
382  void *user_data);
383 
392 PJ_DECL(void*) pj_activesock_get_user_data(pj_activesock_t *asock);
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 
528  pj_ioqueue_op_key_t *send_key,
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
536 
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 
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_set_user_data(pj_activesock_t *asock, void *user_data)
int pj_bool_t
Definition: types.h:71
pj_status_t pj_activesock_close(pj_activesock_t *asock)
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)
int concurrency
Definition: activesock.h:233
pj_status_t pj_activesock_start_recvfrom(pj_activesock_t *asock, pj_pool_t *pool, unsigned buff_size, pj_uint32_t flags)
pj_bool_t(* on_data_sent)(pj_activesock_t *asock, pj_ioqueue_op_key_t *send_key, pj_ssize_t sent)
Definition: activesock.h:129
pj_bool_t(* on_connect_complete)(pj_activesock_t *asock, pj_status_t status)
Definition: activesock.h:189
pj_grp_lock_t * grp_lock
Definition: activesock.h:204
struct pj_activesock_t pj_activesock_t
Definition: activesock.h:51
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)
int pj_status_t
Definition: types.h:68
Definition: sock.h:603
Definition: activesock.h:56
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:109
Definition: ioqueue.h:209
void pj_sockaddr_t
Definition: types.h:267
pj_status_t pj_activesock_start_connect(pj_activesock_t *asock, pj_pool_t *pool, const pj_sockaddr_t *remaddr, int addr_len)
struct pj_grp_lock_t pj_grp_lock_t
Definition: types.h:242
struct pj_ioqueue_t pj_ioqueue_t
Definition: types.h:210
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:148
unsigned int pj_uint32_t
Definition: types.h:43
pj_status_t pj_activesock_start_read2(pj_activesock_t *asock, pj_pool_t *pool, unsigned buff_size, void *readbuf[], pj_uint32_t flags)
unsigned async_cnt
Definition: activesock.h:218
#define PJ_END_DECL
Definition: config.h:1067
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:84
I/O Dispatching Mechanism.
pj_status_t pj_activesock_start_recvfrom2(pj_activesock_t *asock, pj_pool_t *pool, unsigned buff_size, void *readbuf[], pj_uint32_t flags)
#define PJ_BEGIN_DECL
Definition: config.h:1066
pj_bool_t whole_data
Definition: activesock.h:248
long pj_sock_t
Definition: types.h:263
pj_status_t pj_activesock_start_accept(pj_activesock_t *asock, pj_pool_t *pool)
long pj_ssize_t
Definition: types.h:64
Definition: pool.h:313
Socket Abstraction.
void * pj_activesock_get_user_data(pj_activesock_t *asock)
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)
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_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:171
Definition: activesock.c:270
void pj_activesock_cfg_default(pj_activesock_cfg *cfg)
size_t pj_size_t
Definition: types.h:58
Definition: activesock.h:199

 


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