Index: pjproject/trunk/pjnath/src/pjturn-client/client_main.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-client/client_main.c	(revision 1904)
+++ pjproject/trunk/pjnath/src/pjturn-client/client_main.c	(revision 1913)
@@ -49,5 +49,5 @@
     pj_bool_t		 quit;
 
-    pj_turn_udp		*udp_rel;
+    pj_turn_sock	*relay;
     pj_sockaddr		 relay_addr;
 
@@ -57,20 +57,21 @@
 static struct options
 {
-    char    *srv_addr;
-    char    *srv_port;
-    char    *realm;
-    char    *user_name;
-    char    *password;
-    pj_bool_t use_fingerprint;
+    pj_bool_t	 use_tcp;
+    char	*srv_addr;
+    char	*srv_port;
+    char	*realm;
+    char	*user_name;
+    char	*password;
+    pj_bool_t	 use_fingerprint;
 } o;
 
 
 static int worker_thread(void *unused);
-static void turn_on_rx_data(pj_turn_udp *udp_rel,
+static void turn_on_rx_data(pj_turn_sock *relay,
 			    const pj_uint8_t *pkt,
 			    unsigned pkt_len,
 			    const pj_sockaddr_t *peer_addr,
 			    unsigned addr_len);
-static void turn_on_state(pj_turn_udp *udp_rel, pj_turn_state_t old_state,
+static void turn_on_state(pj_turn_sock *relay, pj_turn_state_t old_state,
 			  pj_turn_state_t new_state);
 
@@ -156,7 +157,7 @@
 	g.thread = NULL;
     }
-    if (g.udp_rel) {
-	pj_turn_udp_destroy(g.udp_rel);
-	g.udp_rel = NULL;
+    if (g.relay) {
+	pj_turn_sock_destroy(g.relay);
+	g.relay = NULL;
     }
     for (i=0; i<PJ_ARRAY_SIZE(g.peer); ++i) {
@@ -243,10 +244,10 @@
 static pj_status_t create_relay(void)
 {
-    pj_turn_udp_cb rel_cb;
+    pj_turn_sock_cb rel_cb;
     pj_stun_auth_cred cred;
     pj_str_t srv;
     pj_status_t status;
 
-    if (g.udp_rel) {
+    if (g.relay) {
 	PJ_LOG(1,(THIS_FILE, "Relay already created"));
 	return -1;
@@ -256,6 +257,8 @@
     rel_cb.on_rx_data = &turn_on_rx_data;
     rel_cb.on_state = &turn_on_state;
-    CHECK( pj_turn_udp_create(&g.stun_config, pj_AF_INET(), &rel_cb, 0,
-			      NULL, &g.udp_rel) );
+    CHECK( pj_turn_sock_create(&g.stun_config, pj_AF_INET(), 
+			       (o.use_tcp? PJ_TURN_TP_TCP : PJ_TURN_TP_UDP),
+			       &rel_cb, 0,
+			       NULL, &g.relay) );
 
     if (o.user_name) {
@@ -272,5 +275,5 @@
 
     srv = pj_str(o.srv_addr);
-    CHECK( pj_turn_udp_init(g.udp_rel,				 /* the relay */
+    CHECK( pj_turn_sock_init(g.relay,				 /* the relay */
 			    &srv,				 /* srv addr */
 			    (o.srv_port?atoi(o.srv_port):PJ_STUN_PORT),/* def port */
@@ -285,11 +288,11 @@
 static void destroy_relay(void)
 {
-    if (g.udp_rel) {
-	pj_turn_udp_destroy(g.udp_rel);
-    }
-}
-
-
-static void turn_on_rx_data(pj_turn_udp *udp_rel,
+    if (g.relay) {
+	pj_turn_sock_destroy(g.relay);
+    }
+}
+
+
+static void turn_on_rx_data(pj_turn_sock *relay,
 			    const pj_uint8_t *pkt,
 			    unsigned pkt_len,
@@ -306,5 +309,5 @@
 
 
-static void turn_on_state(pj_turn_udp *udp_rel, pj_turn_state_t old_state,
+static void turn_on_state(pj_turn_sock *relay, pj_turn_state_t old_state,
 			  pj_turn_state_t new_state)
 {
@@ -314,9 +317,9 @@
     if (new_state == PJ_TURN_STATE_READY) {
 	pj_turn_session_info info;
-	pj_turn_udp_get_info(udp_rel, &info);
+	pj_turn_sock_get_info(relay, &info);
 	pj_memcpy(&g.relay_addr, &info.relay_addr, sizeof(pj_sockaddr));
-    } else if (new_state > PJ_TURN_STATE_READY && g.udp_rel) {
+    } else if (new_state > PJ_TURN_STATE_READY && g.relay) {
 	PJ_LOG(3,(THIS_FILE, "Relay shutting down.."));
-	g.udp_rel = NULL;
+	g.relay = NULL;
     }
 }
@@ -327,6 +330,6 @@
     char client_state[20], relay_addr[80], peer0_addr[80], peer1_addr[80];
 
-    if (g.udp_rel) {
-	pj_turn_udp_get_info(g.udp_rel, &info);
+    if (g.relay) {
+	pj_turn_sock_get_info(g.relay, &info);
 	strcpy(client_state, pj_turn_state_name(info.state));
 	if (info.state >= PJ_TURN_STATE_READY)
@@ -358,5 +361,5 @@
 	  peer1_addr);
     puts("+-----------------------------------+                                |");
-    puts("| q  Quit        d  Dump            | 1  Send data to relay adderss  |");
+    puts("| q  Quit                  d  Dump  | 1  Send data to relay adderss  |");
     puts("+-----------------------------------+--------------------------------+");
     printf(">>> ");
@@ -385,5 +388,5 @@
 	    break;
 	case 's':
-	    if (g.udp_rel == NULL) {
+	    if (g.relay == NULL) {
 		puts("Error: no relay");
 		continue;
@@ -395,5 +398,5 @@
 
 	    strcpy(input, "Hello from client");
-	    status = pj_turn_udp_sendto(g.udp_rel, (const pj_uint8_t*)input, 
+	    status = pj_turn_sock_sendto(g.relay, (const pj_uint8_t*)input, 
 					strlen(input)+1, 
 					&peer->addr, 
@@ -403,5 +406,5 @@
 	    break;
 	case 'b':
-	    if (g.udp_rel == NULL) {
+	    if (g.relay == NULL) {
 		puts("Error: no relay");
 		continue;
@@ -412,11 +415,14 @@
 		peer = &g.peer[1];
 
-	    status = pj_turn_udp_bind_channel(g.udp_rel, &peer->addr,
+	    status = pj_turn_sock_bind_channel(g.relay, &peer->addr,
 					      pj_sockaddr_get_len(&peer->addr));
 	    if (status != PJ_SUCCESS)
 		my_perror("turn_udp_bind_channel() failed", status);
 	    break;
+	case 'd':
+	    pj_pool_factory_dump(&g.cp.factory, PJ_TRUE);
+	    break;
 	case 'x':
-	    if (g.udp_rel == NULL) {
+	    if (g.relay == NULL) {
 		puts("Error: no relay");
 		continue;
@@ -426,5 +432,5 @@
 	case '0':
 	case '1':
-	    if (g.udp_rel == NULL) {
+	    if (g.relay == NULL) {
 		puts("No relay");
 		break;
@@ -451,8 +457,9 @@
     puts("");
     puts("and OPTIONS:");
-    puts(" --realm, -r       Set realm of the credential");
-    puts(" --username, -u    Set username of the credential");
-    puts(" --password, -p    Set password of the credential");
-    puts(" --fingerprint, -F Use fingerprint for outgoing requests");
+    puts(" --tcp, -T             Use TCP to connect to TURN server");
+    puts(" --realm, -r REALM     Set realm of the credential to REALM");
+    puts(" --username, -u UID    Set username of the credential to UID");
+    puts(" --password, -p PASSWD Set password of the credential to PASSWD");
+    puts(" --fingerprint, -F     Use fingerprint for outgoing requests");
     puts(" --help, -h");
 }
@@ -465,5 +472,5 @@
 	{ "password",	1, 0, 'p'},
 	{ "fingerprint",0, 0, 'F'},
-	{ "data",	1, 0, 'D'},
+	{ "tcp",        0, 0, 'T'},
 	{ "help",	0, 0, 'h'}
     };
@@ -472,5 +479,5 @@
     pj_status_t status;
 
-    while((c=pj_getopt_long(argc,argv, "r:u:p:N:hF", long_options, &opt_id))!=-1) {
+    while((c=pj_getopt_long(argc,argv, "r:u:p:N:hFT", long_options, &opt_id))!=-1) {
 	switch (c) {
 	case 'r':
@@ -488,4 +495,7 @@
 	case 'F':
 	    o.use_fingerprint = PJ_TRUE;
+	    break;
+	case 'T':
+	    o.use_tcp = PJ_TRUE;
 	    break;
 
