Hi PJSIP developers, I am trying to use PJSIP to transfer a file over TCP. I am stuck in my code and I'm wondering if usage of PJSIP code makes sense at all for the purpose of transferring a file over TCP. If you don't have the time to correct specific code, any hint about the proper usage of modules, layers, etc. could be of great help. My last try is the following: /**************************************************************************************************************************************************/ // Headers /* Module to register on_rx_request callback */ static pjsip_module mod_simpleua = {NULL,NULL,{ "mod-simpleua", 12 },-1,PJSIP_MOD_PRIORITY_APPLICATION, NULL,NULL,NULL,NULL,&on_rx_request,NULL,NULL, NULL,NULL,}; // More variables and prototypes int main(int argc, char *argv[]) { // More variables /* Create a pool factory to allocate memory. */ pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0); /* Create global endpoint. */ pjsip_endpt_create(&caching_pool.factory, endpt_name, &g_endpt); /* Start transaction layer module. */ pjsip_tsx_layer_init_module(g_endpt); /* Initialize UA layer module. */ pjsip_ua_init_module( g_endpt, NULL ); /* Register module to receive incoming requests. */ pjsip_endpt_register_module(g_endpt, &mod_simpleua); /* Initialize the callback for INVITE session: */ inv_cb.on_state_changed = &call_on_state_changed; // Callback to be called when the file transfer is completed. inv_cb.on_media_update = &call_on_media_update; // Callback to be called when SDP negotiation is done. Should file transfer be implemented here? pjsip_inv_usage_init(g_endpt, &inv_cb); /* If URL is specified, then request migration immediately */ if (argc > 1) { // Variables and functions in between to prepare parameters used in functions. /* Create UAC dialog */ status = pjsip_dlg_create_uac( pjsip_ua_instance(), &local_uri, &local_uri, &dst_uri, &dst_uri, &dlg); /* Acquire one TCP transport. */ pjsip_endpt_acquire_transport2(g_endpt, PJSIP_TRANSPORT_TCP,&rem_addr,sizeof(rem_addr),NULL, NULL, // TODO Here goes the file data to be transferred &tcp); /* Creates arbitrary request */ pjsip_endpt_create_request( g_endpt, &method, &target_url, &from, &to, &contact, &call_id, CSEQ_VALUE, &body, &tdata ); /*Create a SDP session description that describes the endpoint capability */ pjmedia_endpt_create_sdp( g_med_endpt,dlg->pool,MAX_MEDIA_CNT,g_sock_info,&local_sdp); /* Manual manipulation of local_sdp to negotiate file transfer with SDP*/ local_sdp->media[0]->desc.media = pj_str("message"); // File transfer RFC 5547 local_sdp->media[0]->desc.transport = pj_str("msrp/tcp"); local_sdp->media[0]->desc.port = 7394; local_sdp->media[0]->desc.port_count = 1; local_sdp->media[0]->attr[0]->name = pj_str("sendonly"); local_sdp->media[0]->attr[1]->name = pj_str("path"); local_sdp->media[0]->attr[1]->value = pj_str("msrp://192.0.0.1:7394/2s93i9;tcp"); local_sdp->media[0]->attr[2]->name = pj_str("file-selector:name:\"dynamic_file.tramp\" "); local_sdp->media[0]->attr[3]->name = pj_str("file-transfer-id"); local_sdp->media[0]->attr[3]->value = pj_str("0123456789"); /* Create the INVITE session, and pass the SDP as the session's initial capability. */ pjsip_inv_create_uac( dlg, local_sdp, 0, &g_inv); } /* Loop until a file transfer request is completed */ for (;!g_complete;) pjsip_endpt_handle_events(g_endpt, &timeout); return 0; }// end of main static pj_bool_t on_rx_request( pjsip_rx_data *rdata) { /* Start TCP listener on arbitrary port. */ pjsip_tcp_transport_start(g_endpt, NULL, 1, &tpfactory); /* Get the listener address */ pj_sockaddr_in_init(&local_addr, &tpfactory->addr_name.host, (pj_uint16_t)tpfactory->addr_name.port); //TODO How should I proceed to receive the file? } static void call_on_media_update( pjsip_inv_session *inv, pj_status_t status) { /* This function sends raw data. Is this the one I should use?*/ status = pjsip_endpt_send_raw(g_endpt, PJSIP_TRANSPORT_TCP,NULL,NULL,NULL,addr,addr,token, &call_on_state_changed); } // Other functions /**************************************************************************************************************************************************/ Thank you, Francisco