BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

sock.h
Go to the documentation of this file.
1 /* $Id: sock.h 5833 2018-07-23 07:15:08Z 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_SOCK_H__
21 #define __PJ_SOCK_H__
22 
28 #include <pj/types.h>
29 
31 
32 
65 extern const pj_uint16_t PJ_AF_UNSPEC;
66 
68 extern const pj_uint16_t PJ_AF_UNIX;
69 
71 #define PJ_AF_LOCAL PJ_AF_UNIX;
72 
74 extern const pj_uint16_t PJ_AF_INET;
75 
77 extern const pj_uint16_t PJ_AF_INET6;
78 
80 extern const pj_uint16_t PJ_AF_PACKET;
81 
83 extern 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)
92 
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
110 
111 # define pj_AF_UNIX() PJ_AF_UNIX
112 
113 # define pj_AF_INET() PJ_AF_INET
114 
115 # define pj_AF_INET6() PJ_AF_INET6
116 
117 # define pj_AF_PACKET() PJ_AF_PACKET
118 
119 # define pj_AF_IRDA() PJ_AF_IRDA
120 #endif
121 
122 
131 extern const pj_uint16_t PJ_SOCK_STREAM;
132 
135 extern const pj_uint16_t PJ_SOCK_DGRAM;
136 
138 extern const pj_uint16_t PJ_SOCK_RAW;
139 
141 extern 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)
150 
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
159 
160 # define pj_SOCK_STREAM() PJ_SOCK_STREAM
161 
162 # define pj_SOCK_DGRAM() PJ_SOCK_DGRAM
163 
164 # define pj_SOCK_RAW() PJ_SOCK_RAW
165 
166 # define pj_SOCK_RDM() PJ_SOCK_RDM
167 #endif
168 
169 
176 extern const pj_uint16_t PJ_SOL_SOCKET;
178 extern const pj_uint16_t PJ_SOL_IP;
180 extern const pj_uint16_t PJ_SOL_TCP;
182 extern const pj_uint16_t PJ_SOL_UDP;
184 extern 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)
192 
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
203 
204 # define pj_SOL_SOCKET() PJ_SOL_SOCKET
205 
206 # define pj_SOL_IP() PJ_SOL_IP
207 
208 # define pj_SOL_TCP() PJ_SOL_TCP
209 
210 # define pj_SOL_UDP() PJ_SOL_UDP
211 
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  */
223 extern 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  */
233 extern const pj_uint16_t PJ_IPTOS_LOWDELAY;
234 
236 extern const pj_uint16_t PJ_IPTOS_THROUGHPUT;
237 
239 extern const pj_uint16_t PJ_IPTOS_RELIABILITY;
240 
243 extern const pj_uint16_t PJ_IPTOS_MINCOST;
244 
245 
246 #if defined(PJ_DLL)
247 
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
262 
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 
280 extern const pj_uint16_t PJ_IPV6_TCLASS;
281 
282 
283 #if defined(PJ_DLL)
284 
285  PJ_DECL(int) pj_IPV6_TCLASS(void);
286 #else
287 
288 # define pj_IPV6_TCLASS() PJ_IPV6_TCLASS
289 #endif
290 
291 
298 extern const pj_uint16_t PJ_SO_TYPE;
299 
301 extern const pj_uint16_t PJ_SO_RCVBUF;
302 
304 extern const pj_uint16_t PJ_SO_SNDBUF;
305 
307 extern const pj_uint16_t PJ_TCP_NODELAY;
308 
311 extern const pj_uint16_t PJ_SO_REUSEADDR;
312 
314 extern const pj_uint16_t PJ_SO_NOSIGPIPE;
315 
318 extern const pj_uint16_t PJ_SO_PRIORITY;
319 
321 extern const pj_uint16_t PJ_IP_MULTICAST_IF;
322 
324 extern const pj_uint16_t PJ_IP_MULTICAST_TTL;
325 
327 extern const pj_uint16_t PJ_IP_MULTICAST_LOOP;
328 
330 extern const pj_uint16_t PJ_IP_ADD_MEMBERSHIP;
331 
334 
335 
336 #if defined(PJ_DLL)
337 
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
373 
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 
416 extern const int PJ_MSG_OOB;
417 
419 extern const int PJ_MSG_PEEK;
420 
422 extern const int PJ_MSG_DONTROUTE;
423 
424 
425 #if defined(PJ_DLL)
426 
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
435 
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 
449 typedef enum pj_socket_sd_type
450 {
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 /* Must undefine s_addr because of pj_in_addr below */
488 #undef s_addr
489 
493 typedef struct pj_in_addr
494 {
496 } pj_in_addr;
497 
498 
502 #define PJ_INET_ADDRSTRLEN 16
503 
507 #define PJ_INET6_ADDRSTRLEN 46
508 
513 #ifndef PJ_SOCKADDR_IN_SIN_ZERO_LEN
514 # define PJ_SOCKADDR_IN_SIN_ZERO_LEN 8
515 #endif
516 
526 {
527 #if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0
528  pj_uint8_t sin_zero_len;
530 #else
532 #endif
536 };
537 
538 
539 #undef s6_addr
540 
544 typedef union pj_in6_addr
545 {
546  /* This is the main entry */
549  /* While these are used for proper alignment */
550  pj_uint32_t u6_addr32[4];
551 
552  /* Do not use this with Winsock2, as this will align pj_sockaddr_in6
553  * to 64-bit boundary and Winsock2 doesn't like it!
554  * Update 26/04/2010:
555  * This is now disabled, see http://trac.pjsip.org/repos/ticket/1058
556  */
557 #if 0 && defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0 && \
558  (!defined(PJ_WIN32) || PJ_WIN32==0)
559  pj_int64_t u6_addr64[2];
560 #endif
561 
562 } pj_in6_addr;
563 
564 
566 #define PJ_IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
567 
569 #define PJ_IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
570 
579 typedef struct pj_sockaddr_in6
580 {
581 #if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0
582  pj_uint8_t sin6_zero_len;
584 #else
586 #endif
592 
593 
602 typedef struct pj_addr_hdr
603 {
604 #if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0
605  pj_uint8_t sa_zero_len;
607 #else
609 #endif
610 } pj_addr_hdr;
611 
612 
616 typedef union pj_sockaddr
617 {
621 } pj_sockaddr;
622 
623 
627 typedef struct pj_ip_mreq {
630 } pj_ip_mreq;
631 
632 
636 typedef struct pj_sockopt_params
637 {
638  /* The number of options to be applied. */
639  unsigned cnt;
640 
641  /* Array of options to be applied. */
642  struct {
643  /* The level at which the option is defined. */
644  int level;
645 
646  /* Option name. */
647  int optname;
648 
649  /* Pointer to the buffer in which the option is specified. */
650  void *optval;
651 
652  /* Buffer size of the buffer pointed by optval. */
653  int optlen;
654  } options[PJ_MAX_SOCKOPT_PARAMS];
656 
657 /*****************************************************************************
658  *
659  * SOCKET ADDRESS MANIPULATION.
660  *
661  *****************************************************************************
662  */
663 
670 PJ_DECL(pj_uint16_t) pj_ntohs(pj_uint16_t netshort);
671 
678 PJ_DECL(pj_uint16_t) pj_htons(pj_uint16_t hostshort);
679 
686 PJ_DECL(pj_uint32_t) pj_ntohl(pj_uint32_t netlong);
687 
694 PJ_DECL(pj_uint32_t) pj_htonl(pj_uint32_t hostlong);
695 
703 PJ_DECL(char*) pj_inet_ntoa(pj_in_addr inaddr);
704 
715 PJ_DECL(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp);
716 
732 PJ_DECL(pj_status_t) pj_inet_pton(int af, const pj_str_t *src, void *dst);
733 
753 PJ_DECL(pj_status_t) pj_inet_ntop(int af, const void *src,
754  char *dst, int size);
755 
773 PJ_DECL(char*) pj_inet_ntop2(int af, const void *src,
774  char *dst, int size);
775 
788 PJ_DECL(char*) pj_sockaddr_print(const pj_sockaddr_t *addr,
789  char *buf, int size,
790  unsigned flags);
791 
804 PJ_DECL(pj_in_addr) pj_inet_addr(const pj_str_t *cp);
805 
818 PJ_DECL(pj_in_addr) pj_inet_addr2(const char *cp);
819 
836  const pj_str_t *cp,
837  pj_uint16_t port);
838 
855 PJ_DECL(pj_status_t) pj_sockaddr_init(int af,
856  pj_sockaddr *addr,
857  const pj_str_t *cp,
858  pj_uint16_t port);
859 
869 PJ_DECL(int) pj_sockaddr_cmp(const pj_sockaddr_t *addr1,
870  const pj_sockaddr_t *addr2);
871 
880 PJ_DECL(void*) pj_sockaddr_get_addr(const pj_sockaddr_t *addr);
881 
889 PJ_DECL(pj_bool_t) pj_sockaddr_has_addr(const pj_sockaddr_t *addr);
890 
900 PJ_DECL(unsigned) pj_sockaddr_get_addr_len(const pj_sockaddr_t *addr);
901 
911 PJ_DECL(unsigned) pj_sockaddr_get_len(const pj_sockaddr_t *addr);
912 
921 PJ_DECL(void) pj_sockaddr_copy_addr(pj_sockaddr *dst,
922  const pj_sockaddr *src);
932 PJ_DECL(void) pj_sockaddr_cp(pj_sockaddr_t *dst, const pj_sockaddr_t *src);
933 
934 /*
935  * If the source's and desired address family matches, copy the address,
936  * otherwise synthesize a new address with the desired address family,
937  * from the source address. This can be useful to generate an IPv4-mapped
938  * IPv6 address.
939  *
940  * @param dst_af Desired address family.
941  * @param dst Destination socket address, invalid if synthesis is
942  * required and failed.
943  * @param src Source socket address.
944  *
945  * @return PJ_SUCCESS on success, or the error status
946  * if synthesis is required and failed.
947  */
948 PJ_DECL(pj_status_t) pj_sockaddr_synthesize(int dst_af,
949  pj_sockaddr_t *dst,
950  const pj_sockaddr_t *src);
951 
960 
967 PJ_DECL(void) pj_sockaddr_in_set_addr(pj_sockaddr_in *addr,
968  pj_uint32_t hostaddr);
969 
986  const pj_str_t *cp);
987 
1002 PJ_DECL(pj_status_t) pj_sockaddr_set_str_addr(int af,
1003  pj_sockaddr *addr,
1004  const pj_str_t *cp);
1005 
1014 PJ_DECL(pj_uint16_t) pj_sockaddr_get_port(const pj_sockaddr_t *addr);
1015 
1023 PJ_DECL(pj_uint16_t) pj_sockaddr_in_get_port(const pj_sockaddr_in *addr);
1024 
1032  pj_uint16_t hostport);
1033 
1042 PJ_DECL(void) pj_sockaddr_in_set_port(pj_sockaddr_in *addr,
1043  pj_uint16_t hostport);
1044 
1095 PJ_DECL(pj_status_t) pj_sockaddr_parse(int af, unsigned options,
1096  const pj_str_t *str,
1097  pj_sockaddr *addr);
1098 
1127 PJ_DECL(pj_status_t) pj_sockaddr_parse2(int af, unsigned options,
1128  const pj_str_t *str,
1129  pj_str_t *hostpart,
1130  pj_uint16_t *port,
1131  int *raf);
1132 
1133 /*****************************************************************************
1134  *
1135  * HOST NAME AND ADDRESS.
1136  *
1137  *****************************************************************************
1138  */
1139 
1146 PJ_DECL(const pj_str_t*) pj_gethostname(void);
1147 
1155 PJ_DECL(pj_in_addr) pj_gethostaddr(void);
1156 
1157 
1158 /*****************************************************************************
1159  *
1160  * SOCKET API.
1161  *
1162  *****************************************************************************
1163  */
1164 
1180 PJ_DECL(pj_status_t) pj_sock_socket(int family,
1181  int type,
1182  int protocol,
1183  pj_sock_t *sock);
1184 
1192 PJ_DECL(pj_status_t) pj_sock_close(pj_sock_t sockfd);
1193 
1194 
1207 PJ_DECL(pj_status_t) pj_sock_bind( pj_sock_t sockfd,
1208  const pj_sockaddr_t *my_addr,
1209  int addrlen);
1210 
1220 PJ_DECL(pj_status_t) pj_sock_bind_in( pj_sock_t sockfd,
1221  pj_uint32_t addr,
1222  pj_uint16_t port);
1223 
1237 PJ_DECL(pj_status_t) pj_sock_bind_random( pj_sock_t sockfd,
1238  const pj_sockaddr_t *addr,
1239  pj_uint16_t port_range,
1240  pj_uint16_t max_try);
1241 
1242 #if PJ_HAS_TCP
1243 
1254 PJ_DECL(pj_status_t) pj_sock_listen( pj_sock_t sockfd,
1255  int backlog );
1256 
1269 PJ_DECL(pj_status_t) pj_sock_accept( pj_sock_t serverfd,
1270  pj_sock_t *newsock,
1271  pj_sockaddr_t *addr,
1272  int *addrlen);
1273 #endif
1274 
1291 PJ_DECL(pj_status_t) pj_sock_connect( pj_sock_t sockfd,
1292  const pj_sockaddr_t *serv_addr,
1293  int addrlen);
1294 
1306 PJ_DECL(pj_status_t) pj_sock_getpeername(pj_sock_t sockfd,
1307  pj_sockaddr_t *addr,
1308  int *namelen);
1309 
1321 PJ_DECL(pj_status_t) pj_sock_getsockname( pj_sock_t sockfd,
1322  pj_sockaddr_t *addr,
1323  int *namelen);
1324 
1339 PJ_DECL(pj_status_t) pj_sock_getsockopt( pj_sock_t sockfd,
1340  pj_uint16_t level,
1341  pj_uint16_t optname,
1342  void *optval,
1343  int *optlen);
1357 PJ_DECL(pj_status_t) pj_sock_setsockopt( pj_sock_t sockfd,
1358  pj_uint16_t level,
1359  pj_uint16_t optname,
1360  const void *optval,
1361  int optlen);
1362 
1373  const pj_sockopt_params *params);
1374 
1391  pj_uint16_t optname,
1392  pj_bool_t auto_retry,
1393  unsigned *buf_size);
1394 
1395 
1407 PJ_DECL(pj_status_t) pj_sock_recv(pj_sock_t sockfd,
1408  void *buf,
1409  pj_ssize_t *len,
1410  unsigned flags);
1411 
1428 PJ_DECL(pj_status_t) pj_sock_recvfrom( pj_sock_t sockfd,
1429  void *buf,
1430  pj_ssize_t *len,
1431  unsigned flags,
1432  pj_sockaddr_t *from,
1433  int *fromlen);
1434 
1447 PJ_DECL(pj_status_t) pj_sock_send(pj_sock_t sockfd,
1448  const void *buf,
1449  pj_ssize_t *len,
1450  unsigned flags);
1451 
1466 PJ_DECL(pj_status_t) pj_sock_sendto(pj_sock_t sockfd,
1467  const void *buf,
1468  pj_ssize_t *len,
1469  unsigned flags,
1470  const pj_sockaddr_t *to,
1471  int tolen);
1472 
1473 #if PJ_HAS_TCP
1474 
1486 PJ_DECL(pj_status_t) pj_sock_shutdown( pj_sock_t sockfd,
1487  int how);
1488 #endif
1489 
1490 /*****************************************************************************
1491  *
1492  * Utilities.
1493  *
1494  *****************************************************************************
1495  */
1496 
1510 PJ_DECL(char *) pj_addr_str_print( const pj_str_t *host_str, int port,
1511  char *buf, int size, unsigned flag);
1512 
1513 
1520 
1521 #endif /* __PJ_SOCK_H__ */
1522 
const pj_uint16_t PJ_IP_DROP_MEMBERSHIP
pj_uint16_t sin_family
Definition: sock.h:531
#define pj_IP_MULTICAST_IF()
Definition: sock.h:395
const pj_uint16_t PJ_SO_RCVBUF
pj_in_addr sin_addr
Definition: sock.h:534
pj_uint16_t pj_ntohs(pj_uint16_t netshort)
const pj_uint16_t PJ_AF_INET6
const pj_uint16_t PJ_IPV6_TCLASS
#define pj_IPTOS_RELIABILITY()
Definition: sock.h:272
const pj_uint16_t PJ_TCP_NODELAY
pj_status_t pj_sock_setsockopt_params(pj_sock_t sockfd, const pj_sockopt_params *params)
const pj_uint16_t PJ_SO_PRIORITY
pj_status_t pj_sock_close(pj_sock_t sockfd)
Definition: sock.h:453
#define pj_AF_INET6()
Definition: sock.h:115
#define pj_SO_RCVBUF()
Definition: sock.h:377
pj_addr_hdr addr
Definition: sock.h:618
pj_status_t pj_sock_shutdown(pj_sock_t sockfd, int how)
pj_uint16_t pj_sockaddr_in_get_port(const pj_sockaddr_in *addr)
pj_status_t pj_sockaddr_in_set_str_addr(pj_sockaddr_in *addr, const pj_str_t *cp)
#define pj_SO_NOSIGPIPE()
Definition: sock.h:389
int pj_bool_t
Definition: types.h:71
#define pj_TCP_NODELAY()
Definition: sock.h:383
Definition: sock.h:636
pj_uint16_t sin_port
Definition: sock.h:533
#define pj_SOCK_RDM()
Definition: sock.h:166
pj_uint8_t s6_addr[16]
Definition: sock.h:547
const int PJ_MSG_DONTROUTE
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)
int pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp)
#define pj_IPTOS_MINCOST()
Definition: sock.h:275
#define pj_IPV6_TCLASS()
Definition: sock.h:288
pj_status_t pj_sock_connect(pj_sock_t sockfd, const pj_sockaddr_t *serv_addr, int addrlen)
pj_status_t pj_sock_getsockopt(pj_sock_t sockfd, pj_uint16_t level, pj_uint16_t optname, void *optval, int *optlen)
pj_in_addr pj_inet_addr(const pj_str_t *cp)
const pj_uint16_t PJ_SOL_IP
pj_socket_sd_type
Definition: sock.h:449
pj_in_addr pj_gethostaddr(void)
pj_uint16_t sin6_port
Definition: sock.h:587
#define pj_AF_UNSPEC()
Definition: sock.h:109
pj_uint32_t sin6_scope_id
Definition: sock.h:590
#define PJ_MAX_SOCKOPT_PARAMS
Definition: config.h:1002
pj_status_t pj_inet_pton(int af, const pj_str_t *src, void *dst)
#define PJ_SOCKADDR_IN_SIN_ZERO_LEN
Definition: sock.h:514
const pj_uint16_t PJ_SOCK_RAW
pj_status_t pj_sockaddr_parse(int af, unsigned options, const pj_str_t *str, pj_sockaddr *addr)
#define pj_SO_PRIORITY()
Definition: sock.h:392
pj_in_addr imr_interface
Definition: sock.h:629
pj_in_addr pj_sockaddr_in_get_addr(const pj_sockaddr_in *addr)
Definition: sock.h:493
const pj_uint16_t PJ_SO_TYPE
Declaration of basic types and utility.
#define pj_IP_DROP_MEMBERSHIP()
Definition: sock.h:407
#define pj_AF_UNIX()
Definition: sock.h:111
int pj_status_t
Definition: types.h:68
#define pj_AF_IRDA()
Definition: sock.h:119
pj_uint16_t pj_htons(pj_uint16_t hostshort)
Definition: sock.h:616
pj_bool_t pj_sockaddr_has_addr(const pj_sockaddr_t *addr)
const pj_uint16_t PJ_SO_SNDBUF
pj_uint16_t sa_family
Definition: sock.h:608
void pj_sockaddr_t
Definition: types.h:267
void pj_sockaddr_copy_addr(pj_sockaddr *dst, const pj_sockaddr *src)
Definition: types.h:119
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)
pj_uint32_t sin6_flowinfo
Definition: sock.h:588
pj_status_t pj_sock_setsockopt_sobuf(pj_sock_t sockfd, pj_uint16_t optname, pj_bool_t auto_retry, unsigned *buf_size)
#define pj_SOCK_RAW()
Definition: sock.h:164
const int PJ_MSG_PEEK
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_RELIABILITY
const pj_uint16_t PJ_SOL_UDP
const pj_uint16_t PJ_SOCK_STREAM
#define pj_SOCK_DGRAM()
Definition: sock.h:162
void pj_sockaddr_in_set_port(pj_sockaddr_in *addr, pj_uint16_t hostport)
Definition: sock.h:452
pj_uint32_t pj_ntohl(pj_uint32_t netlong)
unsigned int pj_uint32_t
Definition: types.h:43
const pj_uint16_t PJ_IPTOS_MINCOST
pj_status_t pj_sock_accept(pj_sock_t serverfd, pj_sock_t *newsock, pj_sockaddr_t *addr, int *addrlen)
void pj_sockaddr_in_set_addr(pj_sockaddr_in *addr, pj_uint32_t hostaddr)
const pj_uint16_t PJ_SOL_IPV6
const pj_uint16_t PJ_IPTOS_LOWDELAY
#define pj_MSG_DONTROUTE()
Definition: sock.h:442
const pj_uint16_t PJ_SO_REUSEADDR
const pj_uint16_t PJ_SO_NOSIGPIPE
#define PJ_END_DECL
Definition: config.h:1202
pj_in_addr pj_inet_addr2(const char *cp)
Definition: sock.h:451
const pj_str_t * pj_gethostname(void)
const pj_uint16_t PJ_AF_IRDA
pj_status_t pj_sock_send(pj_sock_t sockfd, const void *buf, pj_ssize_t *len, unsigned flags)
const pj_uint16_t PJ_SOCK_RDM
const pj_uint16_t PJ_AF_UNIX
pj_status_t pj_sock_bind_in(pj_sock_t sockfd, pj_uint32_t addr, pj_uint16_t port)
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_status_t pj_sock_setsockopt(pj_sock_t sockfd, pj_uint16_t level, pj_uint16_t optname, const void *optval, int optlen)
#define pj_IP_ADD_MEMBERSHIP()
Definition: sock.h:404
#define pj_MSG_PEEK()
Definition: sock.h:439
pj_sockaddr_in6 ipv6
Definition: sock.h:620
#define PJ_BEGIN_DECL
Definition: config.h:1201
long pj_sock_t
Definition: types.h:263
void pj_sockaddr_cp(pj_sockaddr_t *dst, const pj_sockaddr_t *src)
pj_status_t pj_sockaddr_set_port(pj_sockaddr *addr, pj_uint16_t hostport)
unsigned pj_sockaddr_get_addr_len(const pj_sockaddr_t *addr)
Definition: sock.h:455
#define pj_SOL_SOCKET()
Definition: sock.h:204
long pj_ssize_t
Definition: types.h:64
pj_status_t pj_sockaddr_init(int af, pj_sockaddr *addr, const pj_str_t *cp, pj_uint16_t port)
const pj_uint16_t PJ_AF_UNSPEC
char * pj_sockaddr_print(const pj_sockaddr_t *addr, char *buf, int size, unsigned flags)
const pj_uint16_t PJ_IP_MULTICAST_TTL
Definition: sock.h:454
pj_status_t pj_sock_bind(pj_sock_t sockfd, const pj_sockaddr_t *my_addr, int addrlen)
#define pj_IPTOS_THROUGHPUT()
Definition: sock.h:269
#define pj_AF_PACKET()
Definition: sock.h:117
const pj_uint16_t PJ_IP_TOS
unsigned char pj_uint8_t
Definition: types.h:55
int pj_sockaddr_cmp(const pj_sockaddr_t *addr1, const pj_sockaddr_t *addr2)
char * pj_addr_str_print(const pj_str_t *host_str, int port, char *buf, int size, unsigned flag)
const pj_uint16_t PJ_IPTOS_THROUGHPUT
#define pj_SOL_UDP()
Definition: sock.h:210
#define pj_SOL_IPV6()
Definition: sock.h:212
char * pj_inet_ntoa(pj_in_addr inaddr)
Definition: sock.h:579
pj_status_t pj_sock_socket(int family, int type, int protocol, pj_sock_t *sock)
const pj_uint16_t PJ_AF_PACKET
pj_status_t pj_sockaddr_set_str_addr(int af, pj_sockaddr *addr, const pj_str_t *cp)
char * pj_inet_ntop2(int af, const void *src, char *dst, int size)
pj_uint16_t pj_sockaddr_get_port(const pj_sockaddr_t *addr)
#define pj_IP_TOS()
Definition: sock.h:263
Definition: sock.h:456
pj_uint32_t s_addr
Definition: sock.h:495
Definition: sock.h:544
#define pj_SO_SNDBUF()
Definition: sock.h:380
const pj_uint16_t PJ_SOL_TCP
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)
const pj_uint16_t PJ_IP_MULTICAST_LOOP
#define pj_SOL_IP()
Definition: sock.h:206
unsigned pj_sockaddr_get_len(const pj_sockaddr_t *addr)
pj_sockaddr_in ipv4
Definition: sock.h:619
#define pj_IPTOS_LOWDELAY()
Definition: sock.h:266
const int PJ_MSG_OOB
char sin_zero[8]
Definition: sock.h:535
pj_status_t pj_sock_recv(pj_sock_t sockfd, void *buf, pj_ssize_t *len, unsigned flags)
#define pj_SO_TYPE()
Definition: sock.h:374
pj_status_t pj_sock_getpeername(pj_sock_t sockfd, pj_sockaddr_t *addr, int *namelen)
#define pj_IP_MULTICAST_LOOP()
Definition: sock.h:401
const pj_uint16_t PJ_AF_INET
pj_status_t pj_sock_getsockname(pj_sock_t sockfd, pj_sockaddr_t *addr, int *namelen)
pj_status_t pj_inet_ntop(int af, const void *src, char *dst, int size)
#define pj_SO_REUSEADDR()
Definition: sock.h:386
Definition: sock.h:525
const pj_uint16_t PJ_SOL_SOCKET
#define pj_MSG_OOB()
Definition: sock.h:436
unsigned short pj_uint16_t
Definition: types.h:49
pj_uint32_t pj_htonl(pj_uint32_t hostlong)
pj_uint16_t sin6_family
Definition: sock.h:585
#define pj_SOL_TCP()
Definition: sock.h:208
const pj_uint16_t PJ_IP_MULTICAST_IF
Definition: sock.h:602
Definition: sock.h:627
#define pj_SOCK_STREAM()
Definition: sock.h:160
#define pj_IP_MULTICAST_TTL()
Definition: sock.h:398
pj_in_addr imr_multiaddr
Definition: sock.h:628
pj_in6_addr sin6_addr
Definition: sock.h:589
void * pj_sockaddr_get_addr(const pj_sockaddr_t *addr)
const pj_uint16_t PJ_IP_ADD_MEMBERSHIP
pj_status_t pj_sock_listen(pj_sock_t sockfd, int backlog)
#define pj_AF_INET()
Definition: sock.h:113

 


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