Index: /pjproject/trunk/pjsip-apps/src/samples/pjsip-perf.c
===================================================================
--- /pjproject/trunk/pjsip-apps/src/samples/pjsip-perf.c	(revision 579)
+++ /pjproject/trunk/pjsip-apps/src/samples/pjsip-perf.c	(revision 580)
@@ -112,4 +112,5 @@
     pj_caching_pool	 cp;
     pj_pool_t		*pool;
+    pj_bool_t		 use_tcp;
     pj_str_t		 local_addr;
     int			 local_port;
@@ -609,9 +610,9 @@
     pj_status_t status;
 
-    /* Add UDP transport. */
+    /* Add UDP/TCP transport. */
     {
 	pj_sockaddr_in addr;
 	pjsip_host_port addrname;
-	pjsip_transport *tp;
+	const char *transport_type;
 
 	pj_memset(&addr, 0, sizeof(addr));
@@ -623,25 +624,45 @@
 	    addrname.host = app.local_addr;
 	    addrname.port = 5060;
-	}
+	} 
 	if (app.local_port != 0)
 	    addrname.port = app.local_port;
 
-	status = pjsip_udp_transport_start( app.sip_endpt, &addr, 
-					    (app.local_addr.slen ? &addrname:NULL),
-					    1, &tp);
+	if (app.use_tcp) {
+	    pj_sockaddr_in local_addr;
+	    pjsip_tpfactory *tpfactory;
+	    
+	    transport_type = "tcp";
+	    pj_sockaddr_in_init(&local_addr, 0, app.local_port);
+	    status = pjsip_tcp_transport_start(app.sip_endpt, &local_addr,
+					       app.thread_count, &tpfactory);
+	    if (status == PJ_SUCCESS) {
+		app.local_addr = tpfactory->addr_name.host;
+		app.local_port = tpfactory->addr_name.port;
+	    }
+	} else {
+	    pjsip_transport *tp;
+
+	    transport_type = "udp";
+	    status = pjsip_udp_transport_start(app.sip_endpt, &addr, 
+					       (app.local_addr.slen ? &addrname:NULL),
+					       app.thread_count, &tp);
+	    if (status == PJ_SUCCESS) {
+		app.local_addr = tp->local_name.host;
+		app.local_port = tp->local_name.port;
+	    }
+
+	}
 	if (status != PJ_SUCCESS) {
-	    app_perror(THIS_FILE, "Unable to start UDP transport", status);
+	    app_perror(THIS_FILE, "Unable to start transport", status);
 	    return status;
 	}
-
-	app.local_addr = tp->local_name.host;
-	app.local_port = tp->local_name.port;
 
 	app.local_uri.ptr = pj_pool_alloc(app.pool, 128);
 	app.local_uri.slen = pj_ansi_sprintf(app.local_uri.ptr, 
-				    	     "<sip:pjsip-perf@%.*s:%d>",
-					     (int)tp->local_name.host.slen,
-					     tp->local_name.host.ptr,
-					     tp->local_name.port);
+				    	     "<sip:pjsip-perf@%.*s:%d;transport=%s>",
+					     (int)app.local_addr.slen,
+					     app.local_addr.ptr,
+					     app.local_port,
+					     transport_type);
 
 	app.local_contact = app.local_uri;
@@ -951,4 +972,5 @@
 	"   --method=METHOD, -m     Set the test method (default: OPTIONS)\n"
 	"   --local-port=PORT, -p   Set local port [default: 5060]\n"
+	"   --use-tcp, -T           Use TCP instead of UDP (default: no)\n"
 	"   --thread-count=N        Set number of worker threads (default=1)\n"
 	"   --stateless, -s         Set client to operate in stateless mode\n"
@@ -988,4 +1010,5 @@
 	{ "real-sdp",	    0, 0, OPT_REAL_SDP },
 	{ "verbose",        0, 0, 'v' },
+	{ "use-tcp",	    0, 0, 'T' },
 	{ NULL, 0, 0, 0 },
     };
@@ -1068,4 +1091,8 @@
 	    break;
 
+	case 'T':
+	    app.use_tcp = PJ_TRUE;
+	    break;
+
 	default:
 	    PJ_LOG(1,(THIS_FILE, 
@@ -1342,5 +1369,4 @@
 int main(int argc, char *argv[])
 {
-    pj_log_set_level(3);
 
     if (create_app() != 0)
@@ -1359,4 +1385,6 @@
 	pj_log_set_level(4);
 	pjsip_endpt_register_module(app.sip_endpt, &msg_logger);
+    } else {
+        pj_log_set_level(3);
     }
 
@@ -1367,10 +1395,13 @@
 	    app.client.stateless)
 	{
-	    PJ_LOG(3,(THIS_FILE, "Info: --stateless option makes no sense for INVITE, ignored."));
+	    PJ_LOG(3,(THIS_FILE, 
+		      "Info: --stateless option makes no sense for INVITE, "
+                      "ignored."));
 	}
     }
 
     if (app.real_sdp) {
-	PJ_LOG(3,(THIS_FILE, "Info: client/server using real SDP from PJMEDIA"));
+	PJ_LOG(3,(THIS_FILE, 
+                  "Info: client/server using real SDP from PJMEDIA"));
     } else {
 	PJ_LOG(3,(THIS_FILE, "Info: client/server using dummy SDP"));
@@ -1399,6 +1430,7 @@
 	
 
-	PJ_LOG(3,(THIS_FILE, "Starting %d %s, please wait..", 
-		  app.client.job_count, test_type));
+	PJ_LOG(3,(THIS_FILE, "Sending %d %s to %.*s, please wait..", 
+		  app.client.job_count, test_type,
+		  (int)app.client.dst_uri.slen, app.client.dst_uri.ptr));
 
 	for (i=0; i<app.thread_count; ++i) {
@@ -1456,16 +1488,19 @@
 
 	printf("Receiving requests on the following URIs:\n"
-	       "  sip:0@%.*s:%d    for stateless handling (non-INVITE only)\n"
-	       "  sip:1@%.*s:%d    for stateful handling (INVITE and non-INVITE)\n"
-	       "  sip:2@%.*s:%d    for call handling (INVITE only)\n",
+	       "  sip:0@%.*s:%d;transport=%s    for stateless handling (non-INVITE only)\n"
+	       "  sip:1@%.*s:%d;transport=%s    for stateful handling (INVITE and non-INVITE)\n"
+	       "  sip:2@%.*s:%d;transport=%s    for call handling (INVITE only)\n",
 	       (int)app.local_addr.slen,
 	       app.local_addr.ptr,
 	       app.local_port,
+	       (app.use_tcp ? "tcp" : "udp"),
 	       (int)app.local_addr.slen,
 	       app.local_addr.ptr,
 	       app.local_port,
+	       (app.use_tcp ? "tcp" : "udp"),
 	       (int)app.local_addr.slen,
 	       app.local_addr.ptr,
-	       app.local_port);
+	       app.local_port,
+	       (app.use_tcp ? "tcp" : "udp"));
 
 	for (i=0; i<app.thread_count; ++i) {
