Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 509)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 563)
@@ -730,5 +730,5 @@
     /* Find empty transport slot */
     for (id=0; id < PJ_ARRAY_SIZE(pjsua_var.tpdata); ++id) {
-	if (pjsua_var.tpdata[id].tp == NULL)
+	if (pjsua_var.tpdata[id].data.ptr == NULL)
 	    break;
     }
@@ -742,5 +742,7 @@
     /* Create the transport */
     if (type == PJSIP_TRANSPORT_UDP) {
-
+	/*
+	 * Create UDP transport.
+	 */
 	pjsua_transport_config config;
 	pj_sock_t sock = PJ_INVALID_SOCKET;
@@ -774,4 +776,48 @@
 	}
 
+
+	/* Save the transport */
+	pjsua_var.tpdata[id].type = type;
+	pjsua_var.tpdata[id].local_name = tp->local_name;
+	pjsua_var.tpdata[id].data.tp = tp;
+
+    } else if (type == PJSIP_TRANSPORT_TCP) {
+	/*
+	 * Create TCP transport.
+	 */
+	pjsua_transport_config config;
+	pjsip_tpfactory *tcp;
+	pj_sockaddr_in local_addr;
+
+	/* Supply default config if it's not specified */
+	if (cfg == NULL) {
+	    pjsua_transport_config_default(&config);
+	    cfg = &config;
+	}
+
+	/* Init local address */
+	pj_sockaddr_in_init(&local_addr, 0, 0);
+
+	if (cfg->port)
+	    local_addr.sin_port = pj_htons((pj_uint16_t)cfg->port);
+
+	if (cfg->ip_addr.s_addr)
+	    local_addr.sin_addr.s_addr = cfg->ip_addr.s_addr;
+
+	/* Create the TCP transport */
+	status = pjsip_tcp_transport_start(pjsua_var.endpt, &local_addr, 1,
+					   &tcp);
+
+	if (status != PJ_SUCCESS) {
+	    pjsua_perror(THIS_FILE, "Error creating SIP TCP listener", 
+			 status);
+	    goto on_return;
+	}
+
+	/* Save the transport */
+	pjsua_var.tpdata[id].type = type;
+	pjsua_var.tpdata[id].local_name = tcp->addr_name;
+	pjsua_var.tpdata[id].data.factory = tcp;
+
     } else {
 	status = PJSIP_EUNSUPTRANSPORT;
@@ -780,6 +826,4 @@
     }
 
-    /* Save the transport */
-    pjsua_var.tpdata[id].tp = tp;
 
     /* Return the ID */
@@ -808,5 +852,5 @@
     /* Find empty transport slot */
     for (id=0; id < PJ_ARRAY_SIZE(pjsua_var.tpdata); ++id) {
-	if (pjsua_var.tpdata[id].tp == NULL)
+	if (pjsua_var.tpdata[id].data.ptr == NULL)
 	    break;
     }
@@ -819,5 +863,7 @@
 
     /* Save the transport */
-    pjsua_var.tpdata[id].tp = tp;
+    pjsua_var.tpdata[id].type = tp->key.type;
+    pjsua_var.tpdata[id].local_name = tp->local_name;
+    pjsua_var.tpdata[id].data.tp = tp;
 
     /* Return the ID */
@@ -843,5 +889,5 @@
 	 ++i) 
     {
-	if (!pjsua_var.tpdata[i].tp)
+	if (!pjsua_var.tpdata[i].data.ptr)
 	    continue;
 
@@ -863,5 +909,5 @@
 					      pjsua_transport_info *info)
 {
-    pjsip_transport *tp;
+    struct transport_data *t = &pjsua_var.tpdata[id];
 
     pj_memset(info, 0, sizeof(*info));
@@ -871,23 +917,48 @@
 
     /* Make sure that transport exists */
-    PJ_ASSERT_RETURN(pjsua_var.tpdata[id].tp != NULL, PJ_EINVAL);
+    PJ_ASSERT_RETURN(pjsua_var.tpdata[id].data.ptr != NULL, PJ_EINVAL);
 
     PJSUA_LOCK();
 
-    tp = pjsua_var.tpdata[id].tp;
-    if (tp == NULL) {
-	PJSUA_UNLOCK();
-	return PJ_EINVALIDOP;
-    }
+    if (pjsua_var.tpdata[id].type == PJSIP_TRANSPORT_UDP) {
+
+	pjsip_transport *tp = t->data.tp;
+
+	if (tp == NULL) {
+	    PJSUA_UNLOCK();
+	    return PJ_EINVALIDOP;
+	}
     
-    info->id = id;
-    info->type = tp->key.type;
-    info->type_name = pj_str(tp->type_name);
-    info->info = pj_str(tp->info);
-    info->flag = tp->flag;
-    info->addr_len = tp->addr_len;
-    info->local_addr = tp->local_addr;
-    info->local_name = tp->local_name;
-    info->usage_count = pj_atomic_get(tp->ref_cnt);
+	info->id = id;
+	info->type = tp->key.type;
+	info->type_name = pj_str(tp->type_name);
+	info->info = pj_str(tp->info);
+	info->flag = tp->flag;
+	info->addr_len = tp->addr_len;
+	info->local_addr = tp->local_addr;
+	info->local_name = tp->local_name;
+	info->usage_count = pj_atomic_get(tp->ref_cnt);
+
+    } else if (pjsua_var.tpdata[id].type == PJSIP_TRANSPORT_TCP) {
+
+	pjsip_tpfactory *factory = t->data.factory;
+
+	if (factory == NULL) {
+	    PJSUA_UNLOCK();
+	    return PJ_EINVALIDOP;
+	}
+    
+	info->id = id;
+	info->type = t->type;
+	info->type_name = pj_str("TCP");
+	info->info = pj_str("TCP transport");
+	info->flag = factory->flag;
+	info->addr_len = sizeof(factory->local_addr);
+	info->local_addr = factory->local_addr;
+	info->local_name = factory->addr_name;
+	info->usage_count = 0;
+
+    }
+
 
     PJSUA_UNLOCK();
@@ -907,5 +978,5 @@
 
     /* Make sure that transport exists */
-    PJ_ASSERT_RETURN(pjsua_var.tpdata[id].tp != NULL, PJ_EINVAL);
+    PJ_ASSERT_RETURN(pjsua_var.tpdata[id].data.ptr != NULL, PJ_EINVAL);
 
 
@@ -927,5 +998,5 @@
 
     /* Make sure that transport exists */
-    PJ_ASSERT_RETURN(pjsua_var.tpdata[id].tp != NULL, PJ_EINVAL);
+    PJ_ASSERT_RETURN(pjsua_var.tpdata[id].data.ptr != NULL, PJ_EINVAL);
 
 
