Changeset 2781


Ignore:
Timestamp:
Jun 22, 2009 2:06:40 PM (11 years ago)
Author:
nanang
Message:

Ticket #758:

  • fixed transport TCP to call on_connect_complete when connect() returns PJ_SUCCESS.
  • added option to enable transport TCP in symbian_ua.
Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp

    r2506 r2781  
    5252//#define SIP_PROXY     "<sip:192.168.0.8;lr>" 
    5353 
     54// 
     55// Set to 1 if TCP is desired (experimental) 
     56// 
     57#define ENABLE_SIP_TCP  0 
    5458 
    5559// 
     
    379383    status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &tcfg, &tid); 
    380384    if (status != PJ_SUCCESS) { 
    381             pjsua_perror(THIS_FILE, "Error creating transport", status); 
     385            pjsua_perror(THIS_FILE, "Error creating UDP transport", status); 
    382386            pjsua_destroy(); 
    383387            return status; 
    384388    } 
    385389 
     390    /* Add TCP transport */ 
     391#if ENABLE_SIP_TCP 
     392    pjsua_transport_config_default(&tcfg); 
     393    tcfg.port = SIP_PORT; 
     394    status = pjsua_transport_create(PJSIP_TRANSPORT_TCP, &tcfg, &tid); 
     395    if (status != PJ_SUCCESS) { 
     396            pjsua_perror(THIS_FILE, "Error creating TCP transport", status); 
     397            pjsua_destroy(); 
     398            return status; 
     399    } 
     400#endif 
     401     
    386402    /* Add account for the transport */ 
    387403    pjsua_acc_add_local(tid, PJ_TRUE, &g_acc_id); 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c

    r2394 r2781  
    806806                                         sizeof(pj_sockaddr_in)); 
    807807    if (status == PJ_SUCCESS) { 
    808         tcp->has_pending_connect = PJ_FALSE; 
     808        on_connect_complete(tcp->asock, PJ_SUCCESS); 
    809809    } else if (status != PJ_EPENDING) { 
    810810        tcp_destroy(&tcp->base, status); 
     
    812812    } 
    813813 
    814     /* Update (again) local address, just in case local address currently 
    815      * set is different now that asynchronous connect() is started. 
    816      */ 
    817     addr_len = sizeof(pj_sockaddr_in); 
    818     if (pj_sock_getsockname(sock, &local_addr, &addr_len)==PJ_SUCCESS) { 
    819         pj_sockaddr_in *tp_addr = (pj_sockaddr_in*)&tcp->base.local_addr; 
    820  
    821         /* Some systems (like old Win32 perhaps) may not set local address 
    822          * properly before socket is fully connected. 
     814    if (tcp->has_pending_connect) { 
     815        /* Update (again) local address, just in case local address currently 
     816         * set is different now that asynchronous connect() is started. 
    823817         */ 
    824         if (tp_addr->sin_addr.s_addr != local_addr.sin_addr.s_addr && 
    825             local_addr.sin_addr.s_addr != 0)  
    826         { 
    827             tp_addr->sin_addr.s_addr = local_addr.sin_addr.s_addr; 
    828             tp_addr->sin_port = local_addr.sin_port; 
    829             sockaddr_to_host_port(tcp->base.pool, &tcp->base.local_name, 
    830                                   &local_addr); 
     818        addr_len = sizeof(pj_sockaddr_in); 
     819        if (pj_sock_getsockname(sock, &local_addr, &addr_len)==PJ_SUCCESS) { 
     820            pj_sockaddr_in *tp_addr = (pj_sockaddr_in*)&tcp->base.local_addr; 
     821 
     822            /* Some systems (like old Win32 perhaps) may not set local address 
     823             * properly before socket is fully connected. 
     824             */ 
     825            if (tp_addr->sin_addr.s_addr != local_addr.sin_addr.s_addr && 
     826                local_addr.sin_addr.s_addr != 0)  
     827            { 
     828                tp_addr->sin_addr.s_addr = local_addr.sin_addr.s_addr; 
     829                tp_addr->sin_port = local_addr.sin_port; 
     830                sockaddr_to_host_port(tcp->base.pool, &tcp->base.local_name, 
     831                                      &local_addr); 
     832            } 
    831833        } 
    832     } 
    833  
    834     if (tcp->has_pending_connect) { 
     834         
    835835        PJ_LOG(4,(tcp->base.obj_name,  
    836836                  "TCP transport %.*s:%d is connecting to %.*s:%d...", 
Note: See TracChangeset for help on using the changeset viewer.