Changeset 1618 for pjproject/trunk/pjsip-apps/src/samples/debug.c
- Timestamp:
- Dec 5, 2007 4:09:59 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/samples/debug.c
r1576 r1618 29 29 */ 30 30 //#include "aectest.c" 31 //#include "strerror.c" 32 31 33 #include <pjlib.h> 34 #include <pjlib-util.h> 32 35 36 #define THIS_FILE "test.c" 37 38 void check_error(const char *func, pj_status_t status) 39 { 40 if (status != PJ_SUCCESS) { 41 char errmsg[PJ_ERR_MSG_SIZE]; 42 pj_strerror(status, errmsg, sizeof(errmsg)); 43 PJ_LOG(1,(THIS_FILE, "%s error: %s", func, errmsg)); 44 exit(1); 45 } 46 } 47 48 #define DO(func) status = func; check_error(#func, status); 49 50 int main() 51 { 52 pj_sock_t sock; 53 pj_sockaddr_in addr; 54 pj_str_t stun_srv = pj_str("stun.fwdnet.net"); 55 pj_caching_pool cp; 56 pj_status_t status; 57 58 DO( pj_init() ); 59 60 pj_caching_pool_init(&cp, NULL, 0); 61 62 DO( pjlib_util_init() ); 63 DO( pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &sock) ); 64 DO( pj_sock_bind_in(sock, 0, 0) ); 65 66 DO( pjstun_get_mapped_addr(&cp.factory, 1, &sock, 67 &stun_srv, 3478, 68 &stun_srv, 3478, 69 &addr) ); 70 71 PJ_LOG(3,(THIS_FILE, "Mapped address is %s:%d", 72 pj_inet_ntoa(addr.sin_addr), 73 (int)pj_ntohs(addr.sin_port))); 74 75 DO( pj_sock_close(sock) ); 76 pj_caching_pool_destroy(&cp); 77 pj_shutdown(); 78 79 return 0; 80 } 81 82 83 #if 0 84 #include <pjlib.h> 33 85 34 86 static void on_accept_complete(pj_ioqueue_key_t *key, … … 88 140 } 89 141 142 #endif
Note: See TracChangeset
for help on using the changeset viewer.