BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

sock.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_SOCK_H__
20#define __PJ_SOCK_H__
21
27#include <pj/types.h>
28#include <pj/compat/socket.h>
29
31
32
65extern const pj_uint16_t PJ_AF_UNSPEC;
66
68extern const pj_uint16_t PJ_AF_UNIX;
69
71#define PJ_AF_LOCAL PJ_AF_UNIX;
72
74extern const pj_uint16_t PJ_AF_INET;
75
77extern const pj_uint16_t PJ_AF_INET6;
78
80extern const pj_uint16_t PJ_AF_PACKET;
81
83extern const pj_uint16_t PJ_AF_IRDA;
84
85/*
86 * Accessor functions for various address family constants. These
87 * functions are provided because Symbian doesn't allow exporting
88 * global variables from a DLL.
89 */
90
91#if defined(PJ_DLL)
93 PJ_DECL(pj_uint16_t) pj_AF_UNSPEC(void);
95 PJ_DECL(pj_uint16_t) pj_AF_UNIX(void);
97 PJ_DECL(pj_uint16_t) pj_AF_INET(void);
99 PJ_DECL(pj_uint16_t) pj_AF_INET6(void);
101 PJ_DECL(pj_uint16_t) pj_AF_PACKET(void);
103 PJ_DECL(pj_uint16_t) pj_AF_IRDA(void);
104#else
105 /* When pjlib is not built as DLL, these accessor functions are
106 * simply a macro to get their constants
107 */
109# define pj_AF_UNSPEC() PJ_AF_UNSPEC
111# define pj_AF_UNIX() PJ_AF_UNIX
113# define pj_AF_INET() PJ_AF_INET
115# define pj_AF_INET6() PJ_AF_INET6
117# define pj_AF_PACKET() PJ_AF_PACKET
119# define pj_AF_IRDA() PJ_AF_IRDA
120#endif
121
122
131extern const pj_uint16_t PJ_SOCK_STREAM;
132
135extern const pj_uint16_t PJ_SOCK_DGRAM;
136
138extern const pj_uint16_t PJ_SOCK_RAW;
139
141extern const pj_uint16_t PJ_SOCK_RDM;
142
143
144/*
145 * Accessor functions for various constants. These functions are provided
146 * because Symbian doesn't allow exporting global variables from a DLL.
147 */
148
149#if defined(PJ_DLL)
151 PJ_DECL(int) pj_SOCK_STREAM(void);
153 PJ_DECL(int) pj_SOCK_DGRAM(void);
155 PJ_DECL(int) pj_SOCK_RAW(void);
157 PJ_DECL(int) pj_SOCK_RDM(void);
158#else
160# define pj_SOCK_STREAM() PJ_SOCK_STREAM
162# define pj_SOCK_DGRAM() PJ_SOCK_DGRAM
164# define pj_SOCK_RAW() PJ_SOCK_RAW
166# define pj_SOCK_RDM() PJ_SOCK_RDM
167#endif
168
169
176extern const pj_uint16_t PJ_SOL_SOCKET;
178extern const pj_uint16_t PJ_SOL_IP;
180extern const pj_uint16_t PJ_SOL_TCP;
182extern const pj_uint16_t PJ_SOL_UDP;
184extern const pj_uint16_t PJ_SOL_IPV6;
185
186/*
187 * Accessor functions for various constants. These functions are provided
188 * because Symbian doesn't allow exporting global variables from a DLL.
189 */
190
191#if defined(PJ_DLL)
193 PJ_DECL(pj_uint16_t) pj_SOL_SOCKET(void);
195 PJ_DECL(pj_uint16_t) pj_SOL_IP(void);
197 PJ_DECL(pj_uint16_t) pj_SOL_TCP(void);
199 PJ_DECL(pj_uint16_t) pj_SOL_UDP(void);
201 PJ_DECL(pj_uint16_t) pj_SOL_IPV6(void);
202#else
204# define pj_SOL_SOCKET() PJ_SOL_SOCKET
206# define pj_SOL_IP() PJ_SOL_IP
208# define pj_SOL_TCP() PJ_SOL_TCP
210# define pj_SOL_UDP() PJ_SOL_UDP
212# define pj_SOL_IPV6() PJ_SOL_IPV6
213#endif
214
215
216/* IP_TOS
217 *
218 * Note:
219 * TOS CURRENTLY DOES NOT WORK IN Windows 2000 and above!
220 * See http://support.microsoft.com/kb/248611
221 */
223extern const pj_uint16_t PJ_IP_TOS;
224
225/*
226 * IP TOS related constats.
227 *
228 * Note:
229 * TOS CURRENTLY DOES NOT WORK IN Windows 2000 and above!
230 * See http://support.microsoft.com/kb/248611
231 */
233extern const pj_uint16_t PJ_IPTOS_LOWDELAY;
234
237
240
243extern const pj_uint16_t PJ_IPTOS_MINCOST;
244
245
246#if defined(PJ_DLL)
248 PJ_DECL(int) pj_IP_TOS(void);
249
251 PJ_DECL(int) pj_IPTOS_LOWDELAY(void);
252
254 PJ_DECL(int) pj_IPTOS_THROUGHPUT(void);
255
257 PJ_DECL(int) pj_IPTOS_RELIABILITY(void);
258
260 PJ_DECL(int) pj_IPTOS_MINCOST(void);
261#else
263# define pj_IP_TOS() PJ_IP_TOS
264
266# define pj_IPTOS_LOWDELAY() PJ_IP_TOS_LOWDELAY
267
269# define pj_IPTOS_THROUGHPUT() PJ_IP_TOS_THROUGHPUT
270
272# define pj_IPTOS_RELIABILITY() PJ_IP_TOS_RELIABILITY
273
275# define pj_IPTOS_MINCOST() PJ_IP_TOS_MINCOST
276#endif
277
278
280extern const pj_uint16_t PJ_IPV6_TCLASS;
281
282
283#if defined(PJ_DLL)
285 PJ_DECL(int) pj_IPV6_TCLASS(void);
286#else
288# define pj_IPV6_TCLASS() PJ_IPV6_TCLASS
289#endif
290
291
298extern const pj_uint16_t PJ_SO_TYPE;
299
301extern const pj_uint16_t PJ_SO_RCVBUF;
302
304extern const pj_uint16_t PJ_SO_SNDBUF;
305
307extern const pj_uint16_t PJ_TCP_NODELAY;
308
311extern const pj_uint16_t PJ_SO_REUSEADDR;
312
314extern const pj_uint16_t PJ_SO_NOSIGPIPE;
315
318extern const pj_uint16_t PJ_SO_PRIORITY;
319
322
325
328
331
334
335
336#if defined(PJ_DLL)
338 PJ_DECL(pj_uint16_t) pj_SO_TYPE(void);
339
341 PJ_DECL(pj_uint16_t) pj_SO_RCVBUF(void);
342
344 PJ_DECL(pj_uint16_t) pj_SO_SNDBUF(void);
345
347 PJ_DECL(pj_uint16_t) pj_TCP_NODELAY(void);
348
350 PJ_DECL(pj_uint16_t) pj_SO_REUSEADDR(void);
351
353 PJ_DECL(pj_uint16_t) pj_SO_NOSIGPIPE(void);
354
356 PJ_DECL(pj_uint16_t) pj_SO_PRIORITY(void);
357
359 PJ_DECL(pj_uint16_t) pj_IP_MULTICAST_IF(void);
360
362 PJ_DECL(pj_uint16_t) pj_IP_MULTICAST_TTL(void);
363
365 PJ_DECL(pj_uint16_t) pj_IP_MULTICAST_LOOP(void);
366
368 PJ_DECL(pj_uint16_t) pj_IP_ADD_MEMBERSHIP(void);
369
371 PJ_DECL(pj_uint16_t) pj_IP_DROP_MEMBERSHIP(void);
372#else
374# define pj_SO_TYPE() PJ_SO_TYPE
375
377# define pj_SO_RCVBUF() PJ_SO_RCVBUF
378
380# define pj_SO_SNDBUF() PJ_SO_SNDBUF
381
383# define pj_TCP_NODELAY() PJ_TCP_NODELAY
384
386# define pj_SO_REUSEADDR() PJ_SO_REUSEADDR
387
389# define pj_SO_NOSIGPIPE() PJ_SO_NOSIGPIPE
390
392# define pj_SO_PRIORITY() PJ_SO_PRIORITY
393
395# define pj_IP_MULTICAST_IF() PJ_IP_MULTICAST_IF
396
398# define pj_IP_MULTICAST_TTL() PJ_IP_MULTICAST_TTL
399
401# define pj_IP_MULTICAST_LOOP() PJ_IP_MULTICAST_LOOP
402
404# define pj_IP_ADD_MEMBERSHIP() PJ_IP_ADD_MEMBERSHIP
405
407# define pj_IP_DROP_MEMBERSHIP() PJ_IP_DROP_MEMBERSHIP
408#endif
409
410
411/*
412 * Flags to be specified in #pj_sock_recv, #pj_sock_send, etc.
413 */
414
416extern const int PJ_MSG_OOB;
417
419extern const int PJ_MSG_PEEK;
420
422extern const int PJ_MSG_DONTROUTE;
423
424
425#if defined(PJ_DLL)
427 PJ_DECL(int) pj_MSG_OOB(void);
428
430 PJ_DECL(int) pj_MSG_PEEK(void);
431
433 PJ_DECL(int) pj_MSG_DONTROUTE(void);
434#else
436# define pj_MSG_OOB() PJ_MSG_OOB
437
439# define pj_MSG_PEEK() PJ_MSG_PEEK
440
442# define pj_MSG_DONTROUTE() PJ_MSG_DONTROUTE
443#endif
444
445
450{
456 PJ_SHUT_RDWR = 2
458
459
460
462#define PJ_INADDR_ANY ((pj_uint32_t)0)
463
465#define PJ_INADDR_NONE ((pj_uint32_t)0xffffffff)
466
468#define PJ_INADDR_BROADCAST ((pj_uint32_t)0xffffffff)
469
470
476#if !defined(PJ_SOMAXCONN)
477# define PJ_SOMAXCONN 5
478#endif
479
480
485#define PJ_INVALID_SOCKET (-1)
486
487/* Undefining UNIX standard library macro such as s_addr is not
488 * recommended as it may cause build issues for anyone who uses
489 * the macro. See #2311 for more details.
490 */
491#if 0
492/* Must undefine s_addr because of pj_in_addr below */
493#undef s_addr
494
495typedef struct pj_in_addr
496{
497 pj_uint32_t s_addr;
498} pj_in_addr;
499
500#else
504typedef struct in_addr pj_in_addr;
505#endif
506
510#define PJ_INET_ADDRSTRLEN 16
511
515#define PJ_INET6_ADDRSTRLEN 46
516
521#ifndef PJ_SOCKADDR_IN_SIN_ZERO_LEN
522# define PJ_SOCKADDR_IN_SIN_ZERO_LEN 8
523#endif
524
534{
535#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0
536 pj_uint8_t sin_zero_len;
538#else
540#endif
544};
545
546
547/* Undefining C standard library macro such as s6_addr is not
548 * recommended as it may cause build issues for anyone who uses
549 * the macro. See #2311 for more details.
550 */
551#if 0
552#undef s6_addr
553
554typedef union pj_in6_addr
555{
556 /* This is the main entry */
557 pj_uint8_t s6_addr[16];
559 /* While these are used for proper alignment */
560 pj_uint32_t u6_addr32[4];
561
562 /* Do not use this with Winsock2, as this will align pj_sockaddr_in6
563 * to 64-bit boundary and Winsock2 doesn't like it!
564 * Update 26/04/2010:
565 * This is now disabled, see https://github.com/pjsip/pjproject/issues/1058
566 */
567#if 0 && defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0 && \
568 (!defined(PJ_WIN32) || PJ_WIN32==0)
569 pj_int64_t u6_addr64[2];
570#endif
571
573#else
577typedef struct in6_addr pj_in6_addr;
578#endif
579
580
582#define PJ_IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
583
585#define PJ_IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
586
595typedef struct pj_sockaddr_in6
596{
597#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0
598 pj_uint8_t sin6_zero_len;
600#else
602#endif
608
609
618typedef struct pj_addr_hdr
619{
620#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0
621 pj_uint8_t sa_zero_len;
623#else
625#endif
627
628
632typedef union pj_sockaddr
633{
638
639
643typedef struct pj_ip_mreq {
646} pj_ip_mreq;
647
648
652typedef struct pj_sockopt_params
653{
655 unsigned cnt;
656
658 struct {
660 int level;
661
664
666 void *optval;
667
672
673/*****************************************************************************
674 *
675 * SOCKET ADDRESS MANIPULATION.
676 *
677 *****************************************************************************
678 */
679
687
694PJ_DECL(pj_uint16_t) pj_htons(pj_uint16_t hostshort);
695
703
711
719PJ_DECL(char*) pj_inet_ntoa(pj_in_addr inaddr);
720
731PJ_DECL(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp);
732
748PJ_DECL(pj_status_t) pj_inet_pton(int af, const pj_str_t *src, void *dst);
749
769PJ_DECL(pj_status_t) pj_inet_ntop(int af, const void *src,
770 char *dst, int size);
771
789PJ_DECL(char*) pj_inet_ntop2(int af, const void *src,
790 char *dst, int size);
791
804PJ_DECL(char*) pj_sockaddr_print(const pj_sockaddr_t *addr,
805 char *buf, int size,
806 unsigned flags);
807
820PJ_DECL(pj_in_addr) pj_inet_addr(const pj_str_t *cp);
821
834PJ_DECL(pj_in_addr) pj_inet_addr2(const char *cp);
835
852 const pj_str_t *cp,
853 pj_uint16_t port);
854
872 pj_sockaddr *addr,
873 const pj_str_t *cp,
874 pj_uint16_t port);
875
885PJ_DECL(int) pj_sockaddr_cmp(const pj_sockaddr_t *addr1,
886 const pj_sockaddr_t *addr2);
887
896PJ_DECL(void*) pj_sockaddr_get_addr(const pj_sockaddr_t *addr);
897
906
916PJ_DECL(unsigned) pj_sockaddr_get_addr_len(const pj_sockaddr_t *addr);
917
927PJ_DECL(unsigned) pj_sockaddr_get_len(const pj_sockaddr_t *addr);
928
938 const pj_sockaddr *src);
948PJ_DECL(void) pj_sockaddr_cp(pj_sockaddr_t *dst, const pj_sockaddr_t *src);
949
965 pj_sockaddr_t *dst,
966 const pj_sockaddr_t *src);
967
976
984 pj_uint32_t hostaddr);
985
1002 const pj_str_t *cp);
1003
1019 pj_sockaddr *addr,
1020 const pj_str_t *cp);
1021
1031
1040
1048 pj_uint16_t hostport);
1049
1059 pj_uint16_t hostport);
1060
1111PJ_DECL(pj_status_t) pj_sockaddr_parse(int af, unsigned options,
1112 const pj_str_t *str,
1113 pj_sockaddr *addr);
1114
1143PJ_DECL(pj_status_t) pj_sockaddr_parse2(int af, unsigned options,
1144 const pj_str_t *str,
1145 pj_str_t *hostpart,
1146 pj_uint16_t *port,
1147 int *raf);
1148
1149/*****************************************************************************
1150 *
1151 * HOST NAME AND ADDRESS.
1152 *
1153 *****************************************************************************
1154 */
1155
1162PJ_DECL(const pj_str_t*) pj_gethostname(void);
1163
1172
1173
1174/*****************************************************************************
1175 *
1176 * SOCKET API.
1177 *
1178 *****************************************************************************
1179 */
1180
1196PJ_DECL(pj_status_t) pj_sock_socket(int family,
1197 int type,
1198 int protocol,
1199 pj_sock_t *sock);
1200
1209
1210
1224 const pj_sockaddr_t *my_addr,
1225 int addrlen);
1226
1237 pj_uint32_t addr,
1238 pj_uint16_t port);
1239
1254 const pj_sockaddr_t *addr,
1255 pj_uint16_t port_range,
1256 pj_uint16_t max_try);
1257
1258#if PJ_HAS_TCP
1271 int backlog );
1272
1286 pj_sock_t *newsock,
1287 pj_sockaddr_t *addr,
1288 int *addrlen);
1289#endif
1290
1308 const pj_sockaddr_t *serv_addr,
1309 int addrlen);
1310
1323 pj_sockaddr_t *addr,
1324 int *namelen);
1325
1338 pj_sockaddr_t *addr,
1339 int *namelen);
1340
1356 pj_uint16_t level,
1357 pj_uint16_t optname,
1358 void *optval,
1359 int *optlen);
1374 pj_uint16_t level,
1375 pj_uint16_t optname,
1376 const void *optval,
1377 int optlen);
1378
1389 const pj_sockopt_params *params);
1390
1407 pj_uint16_t optname,
1408 pj_bool_t auto_retry,
1409 unsigned *buf_size);
1410
1411
1424 void *buf,
1425 pj_ssize_t *len,
1426 unsigned flags);
1427
1445 void *buf,
1446 pj_ssize_t *len,
1447 unsigned flags,
1448 pj_sockaddr_t *from,
1449 int *fromlen);
1450
1464 const void *buf,
1465 pj_ssize_t *len,
1466 unsigned flags);
1467
1483 const void *buf,
1484 pj_ssize_t *len,
1485 unsigned flags,
1486 const pj_sockaddr_t *to,
1487 int tolen);
1488
1489#if PJ_HAS_TCP
1503 int how);
1504#endif
1505
1506/*****************************************************************************
1507 *
1508 * Utilities.
1509 *
1510 *****************************************************************************
1511 */
1512
1526PJ_DECL(char *) pj_addr_str_print( const pj_str_t *host_str, int port,
1527 char *buf, int size, unsigned flag);
1528
1547 int type,
1548 int protocol,
1549 pj_sock_t sv[2]);
1550
1557
1558#endif /* __PJ_SOCK_H__ */
1559
unsigned char pj_uint8_t
Definition: types.h:55
long pj_ssize_t
Definition: types.h:64
int pj_bool_t
Definition: types.h:71
unsigned short pj_uint16_t
Definition: types.h:49
long pj_sock_t
Definition: types.h:263
void pj_sockaddr_t
Definition: types.h:267
int pj_status_t
Definition: types.h:68
unsigned int pj_uint32_t
Definition: types.h:43
void pj_sockaddr_in_set_addr(pj_sockaddr_in *addr, pj_uint32_t hostaddr)
#define pj_AF_PACKET()
Definition: sock.h:117
#define pj_IPTOS_RELIABILITY()
Definition: sock.h:272
const pj_uint16_t PJ_IP_ADD_MEMBERSHIP
const pj_uint16_t PJ_SO_PRIORITY
pj_status_t pj_sockaddr_init(int af, pj_sockaddr *addr, const pj_str_t *cp, pj_uint16_t port)
pj_status_t pj_sockaddr_parse(int af, unsigned options, const pj_str_t *str, pj_sockaddr *addr)
pj_status_t pj_sock_bind(pj_sock_t sockfd, const pj_sockaddr_t *my_addr, int addrlen)
#define pj_SOCK_RDM()
Definition: sock.h:166
#define pj_SO_SNDBUF()
Definition: sock.h:380
const pj_uint16_t PJ_SOCK_STREAM
const pj_uint16_t PJ_SO_SNDBUF
pj_status_t pj_sock_send(pj_sock_t sockfd, const void *buf, pj_ssize_t *len, unsigned flags)
void * pj_sockaddr_get_addr(const pj_sockaddr_t *addr)
char * pj_sockaddr_print(const pj_sockaddr_t *addr, char *buf, int size, unsigned flags)
pj_uint16_t pj_htons(pj_uint16_t hostshort)
pj_socket_sd_type
Definition: sock.h:450
const pj_uint16_t PJ_SO_TYPE
#define pj_SOL_IPV6()
Definition: sock.h:212
#define pj_SOCK_RAW()
Definition: sock.h:164
#define pj_MSG_DONTROUTE()
Definition: sock.h:442
pj_status_t pj_sock_bind_random(pj_sock_t sockfd, const pj_sockaddr_t *addr, pj_uint16_t port_range, pj_uint16_t max_try)
pj_uint16_t pj_sockaddr_get_port(const pj_sockaddr_t *addr)
#define pj_IPTOS_THROUGHPUT()
Definition: sock.h:269
pj_status_t pj_sock_close(pj_sock_t sockfd)
pj_in_addr pj_inet_addr2(const char *cp)
const pj_uint16_t PJ_SO_NOSIGPIPE
pj_status_t pj_sockaddr_in_set_str_addr(pj_sockaddr_in *addr, const pj_str_t *cp)
const pj_uint16_t PJ_IP_MULTICAST_LOOP
pj_in_addr pj_sockaddr_in_get_addr(const pj_sockaddr_in *addr)
const pj_uint16_t PJ_SOL_SOCKET
#define pj_IP_MULTICAST_TTL()
Definition: sock.h:398
const pj_uint16_t PJ_AF_INET6
const pj_uint16_t PJ_IPTOS_LOWDELAY
pj_status_t pj_sockaddr_parse2(int af, unsigned options, const pj_str_t *str, pj_str_t *hostpart, pj_uint16_t *port, int *raf)
#define pj_IPTOS_LOWDELAY()
Definition: sock.h:266
#define pj_SO_TYPE()
Definition: sock.h:374
int pj_sockaddr_cmp(const pj_sockaddr_t *addr1, const pj_sockaddr_t *addr2)
pj_status_t pj_inet_ntop(int af, const void *src, char *dst, int size)
pj_status_t pj_sock_accept(pj_sock_t serverfd, pj_sock_t *newsock, pj_sockaddr_t *addr, int *addrlen)
const pj_uint16_t PJ_SOCK_RAW
const pj_str_t * pj_gethostname(void)
pj_status_t pj_sockaddr_set_port(pj_sockaddr *addr, pj_uint16_t hostport)
pj_uint32_t pj_ntohl(pj_uint32_t netlong)
const pj_uint16_t PJ_SOL_IPV6
#define pj_SOL_TCP()
Definition: sock.h:208
#define pj_AF_INET6()
Definition: sock.h:115
#define pj_IP_DROP_MEMBERSHIP()
Definition: sock.h:407
const pj_uint16_t PJ_AF_IRDA
#define PJ_SOCKADDR_IN_SIN_ZERO_LEN
Definition: sock.h:522
const pj_uint16_t PJ_IP_TOS
const int PJ_MSG_DONTROUTE
#define pj_SO_NOSIGPIPE()
Definition: sock.h:389
const pj_uint16_t PJ_SOL_UDP
pj_status_t pj_sock_listen(pj_sock_t sockfd, int backlog)
const pj_uint16_t PJ_SO_REUSEADDR
#define pj_AF_IRDA()
Definition: sock.h:119
const pj_uint16_t PJ_AF_UNIX
#define pj_AF_UNSPEC()
Definition: sock.h:109
const pj_uint16_t PJ_SO_RCVBUF
const pj_uint16_t PJ_TCP_NODELAY
const pj_uint16_t PJ_IPTOS_RELIABILITY
#define pj_SOL_IP()
Definition: sock.h:206
const pj_uint16_t PJ_IPTOS_MINCOST
pj_uint32_t pj_htonl(pj_uint32_t hostlong)
const int PJ_MSG_PEEK
pj_status_t pj_sock_bind_in(pj_sock_t sockfd, pj_uint32_t addr, pj_uint16_t port)
void pj_sockaddr_in_set_port(pj_sockaddr_in *addr, pj_uint16_t hostport)
pj_status_t pj_sockaddr_synthesize(int dst_af, pj_sockaddr_t *dst, const pj_sockaddr_t *src)
pj_uint16_t pj_ntohs(pj_uint16_t netshort)
const pj_uint16_t PJ_IPV6_TCLASS
#define pj_IP_MULTICAST_IF()
Definition: sock.h:395
const pj_uint16_t PJ_SOL_IP
#define pj_TCP_NODELAY()
Definition: sock.h:383
#define pj_AF_INET()
Definition: sock.h:113
pj_status_t pj_inet_pton(int af, const pj_str_t *src, void *dst)
pj_status_t pj_sock_getsockopt(pj_sock_t sockfd, pj_uint16_t level, pj_uint16_t optname, void *optval, int *optlen)
const pj_uint16_t PJ_SOCK_RDM
#define pj_IPTOS_MINCOST()
Definition: sock.h:275
pj_status_t pj_sock_sendto(pj_sock_t sockfd, const void *buf, pj_ssize_t *len, unsigned flags, const pj_sockaddr_t *to, int tolen)
#define pj_IP_ADD_MEMBERSHIP()
Definition: sock.h:404
int pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp)
const pj_uint16_t PJ_IP_MULTICAST_TTL
#define pj_SO_RCVBUF()
Definition: sock.h:377
pj_status_t pj_sock_setsockopt(pj_sock_t sockfd, pj_uint16_t level, pj_uint16_t optname, const void *optval, int optlen)
#define pj_SO_REUSEADDR()
Definition: sock.h:386
const pj_uint16_t PJ_SOCK_DGRAM
pj_status_t pj_sock_recvfrom(pj_sock_t sockfd, void *buf, pj_ssize_t *len, unsigned flags, pj_sockaddr_t *from, int *fromlen)
#define pj_SOCK_DGRAM()
Definition: sock.h:162
pj_status_t pj_sock_connect(pj_sock_t sockfd, const pj_sockaddr_t *serv_addr, int addrlen)
const pj_uint16_t PJ_AF_INET
pj_status_t pj_sockaddr_set_str_addr(int af, pj_sockaddr *addr, const pj_str_t *cp)
pj_status_t pj_sock_socketpair(int family, int type, int protocol, pj_sock_t sv[2])
char * pj_inet_ntoa(pj_in_addr inaddr)
struct in_addr pj_in_addr
Definition: sock.h:504
#define pj_SOL_UDP()
Definition: sock.h:210
const int PJ_MSG_OOB
const pj_uint16_t PJ_AF_PACKET
#define pj_AF_UNIX()
Definition: sock.h:111
pj_in_addr pj_gethostaddr(void)
pj_in_addr pj_inet_addr(const pj_str_t *cp)
#define pj_IP_TOS()
Definition: sock.h:263
#define pj_IPV6_TCLASS()
Definition: sock.h:288
pj_status_t pj_sock_setsockopt_params(pj_sock_t sockfd, const pj_sockopt_params *params)
#define pj_SOL_SOCKET()
Definition: sock.h:204
#define pj_SO_PRIORITY()
Definition: sock.h:392
pj_status_t pj_sock_setsockopt_sobuf(pj_sock_t sockfd, pj_uint16_t optname, pj_bool_t auto_retry, unsigned *buf_size)
unsigned pj_sockaddr_get_addr_len(const pj_sockaddr_t *addr)
#define pj_MSG_PEEK()
Definition: sock.h:439
pj_status_t pj_sock_shutdown(pj_sock_t sockfd, int how)
pj_status_t pj_sock_getsockname(pj_sock_t sockfd, pj_sockaddr_t *addr, int *namelen)
pj_uint16_t pj_sockaddr_in_get_port(const pj_sockaddr_in *addr)
pj_bool_t pj_sockaddr_has_addr(const pj_sockaddr_t *addr)
const pj_uint16_t PJ_IP_MULTICAST_IF
const pj_uint16_t PJ_AF_UNSPEC
#define pj_IP_MULTICAST_LOOP()
Definition: sock.h:401
unsigned pj_sockaddr_get_len(const pj_sockaddr_t *addr)
#define pj_SOCK_STREAM()
Definition: sock.h:160
char * pj_addr_str_print(const pj_str_t *host_str, int port, char *buf, int size, unsigned flag)
void pj_sockaddr_copy_addr(pj_sockaddr *dst, const pj_sockaddr *src)
pj_status_t pj_sockaddr_in_init(pj_sockaddr_in *addr, const pj_str_t *cp, pj_uint16_t port)
const pj_uint16_t PJ_IPTOS_THROUGHPUT
void pj_sockaddr_cp(pj_sockaddr_t *dst, const pj_sockaddr_t *src)
pj_status_t pj_sock_getpeername(pj_sock_t sockfd, pj_sockaddr_t *addr, int *namelen)
pj_status_t pj_sock_socket(int family, int type, int protocol, pj_sock_t *sock)
const pj_uint16_t PJ_SOL_TCP
pj_status_t pj_sock_recv(pj_sock_t sockfd, void *buf, pj_ssize_t *len, unsigned flags)
const pj_uint16_t PJ_IP_DROP_MEMBERSHIP
char * pj_inet_ntop2(int af, const void *src, char *dst, int size)
#define pj_MSG_OOB()
Definition: sock.h:436
struct in6_addr pj_in6_addr
Definition: sock.h:577
@ PJ_SHUT_RDWR
Definition: sock.h:456
@ PJ_SD_RECEIVE
Definition: sock.h:451
@ PJ_SD_BOTH
Definition: sock.h:455
@ PJ_SHUT_RD
Definition: sock.h:452
@ PJ_SHUT_WR
Definition: sock.h:454
@ PJ_SD_SEND
Definition: sock.h:453
#define PJ_BEGIN_DECL
Definition: config.h:1284
#define PJ_MAX_SOCKOPT_PARAMS
Definition: config.h:1085
#define PJ_END_DECL
Definition: config.h:1285
Definition: sock.h:619
pj_uint16_t sa_family
Definition: sock.h:624
Definition: sock.h:643
pj_in_addr imr_interface
Definition: sock.h:645
pj_in_addr imr_multiaddr
Definition: sock.h:644
Definition: sock.h:596
pj_uint32_t sin6_flowinfo
Definition: sock.h:604
pj_uint16_t sin6_family
Definition: sock.h:601
pj_in6_addr sin6_addr
Definition: sock.h:605
pj_uint32_t sin6_scope_id
Definition: sock.h:606
pj_uint16_t sin6_port
Definition: sock.h:603
Definition: sock.h:534
pj_uint16_t sin_port
Definition: sock.h:541
pj_uint16_t sin_family
Definition: sock.h:539
pj_in_addr sin_addr
Definition: sock.h:542
char sin_zero_pad[8]
Definition: sock.h:543
Definition: sock.h:653
int optname
Definition: sock.h:663
struct pj_sockopt_params::@1 options[PJ_MAX_SOCKOPT_PARAMS]
unsigned cnt
Definition: sock.h:655
int level
Definition: sock.h:660
int optlen
Definition: sock.h:669
void * optval
Definition: sock.h:666
Definition: types.h:120
Declaration of basic types and utility.
Definition: sock.h:633
pj_sockaddr_in6 ipv6
Definition: sock.h:636
pj_addr_hdr addr
Definition: sock.h:634
pj_sockaddr_in ipv4
Definition: sock.h:635

 


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