Hi Benny: Thanks your reply. I have been tried your solution before. unfortunately, the server does not obey our "hopefully". Just the INVITE method brings the extern param ";x-my-acc-id=1", and the others method are not. So I wants use the incoming port to decide which account to use. It can easy work in UDP transport, because I can create two UDP transport, then use the? the? transport id to bind the account. Ex: cfg_1.port = 5060; pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg_1, tp_id_1) acc_cfg_1.transport_id = tp_id_1; pjsua_acc_add(&acc_cfg_1, PJ_TRUE, &acc_id_1); cfg_2.port = 5062; pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg_2, tp_id_2) acc_cfg_2.transport_id = tp_id_2; pjsua_acc_add(&acc_cfg_2, PJ_TRUE, &acc_id_2); But, the above way can not use in the TCP transport, event I enable cfg.allow_contact_rewrite = PJ_TRUE. As far I understand, the pjsua_transport_create( ) for PJSIP_TRANSPORT_TCP just can only call it once. If call it twice, the system will return PJSIP_ETYPEEXISTS. Besides, it just create a port to listen, not create port to connect to SIP server. I trace the transport, the tp_mgr is using remote ip and port as the hash key. If the account 1 has already connect to server, and the account2 will found the transport in the tp_mgr. Because of the destination (remote ip and port) is the same. I have no idea to modify the code to reach my goal anymore. Do you have any idea how to reach it? Best Regards DaCheng --- 09/12/9 (?)?Benny Prijono <bennylp at teluu.com> ??? ???: Benny Prijono <bennylp at teluu.com> ??: Re: [pjsip] [help] How to using different tcp port to register server. ???: "pjsip list" <pjsip at lists.pjsip.org> ??: 2009?12?9?,?,??4:51 On Sat, Nov 28, 2009 at 5:22 AM, DaCheng <ato_wu at yahoo.com.tw> wrote: Hi all: I am using version 1.4 to implement my application. I set two accounts and use "tcp" connection to register a sip server. The pjsip always to use one tcp port to connect to sip server for any account. My question is: If I set account 1(#7219) is equal to account 2(#7219), and register to sip server. The other phone make a call to (#7219), my pc will recevie two INVITE request. Because the pjsua_acc_find_for_incoming() use "To" header to judge this request is for which account. Those two INVITE request almost the same, the pjsip always return account 1 in pjsua_acc_find_for_incoming() funtion. So I want those two accounts that have its tcp connection port and uses its tcp port to register sip server. Then I can using the incoming port to judge the INVITE request is for which account roughly. Why are you registering two identical accounts in the first place? Or if you really must use two identical accounts, you could probably add a custom Contact URI parameter in pjsua_acc_config.contact_uri_params (for example, ";x-my-acc-id=1") to distinguish the two accounts. This way, *hopefully* the server will add this parameter to the Request URI of incoming INVITE, so that you can decide which account to use. Cheers ?enny -----????????----- _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip at lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org ___________________________________________________ ??????? ? ???????????????? http://messenger.yahoo.com.tw/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20091209/7d879c6d/attachment.html>