Index: pjproject/trunk/pjsip/include/pjsip/sip_config.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsip/sip_config.h	(revision 5868)
+++ pjproject/trunk/pjsip/include/pjsip/sip_config.h	(revision 5869)
@@ -773,4 +773,19 @@
 
 /**
+ * Initial timeout interval to be applied to incoming transports (i.e. server
+ * side) when no data received after a successful connection. Value is in
+ * seconds. Disable the timeout by setting it to 0.
+ *
+ * Note that even when this is disable, the connection might still get closed
+ * when it is idle or not referred anymore. Have a look at \a
+ * PJSIP_TRANSPORT_SERVER_IDLE_TIME
+ *
+ * Default: 0 (disabled)
+ */
+#ifndef PJSIP_TCP_INITIAL_TIMEOUT
+#   define PJSIP_TCP_INITIAL_TIMEOUT	    0
+#endif
+
+/**
  * Set the interval to send keep-alive packet for TLS transports.
  * If the value is zero, keep-alive will be disabled for TLS.
Index: pjproject/trunk/pjsip/include/pjsip/sip_transport_tcp.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsip/sip_transport_tcp.h	(revision 5868)
+++ pjproject/trunk/pjsip/include/pjsip/sip_transport_tcp.h	(revision 5869)
@@ -112,4 +112,13 @@
      */
     pj_sockopt_params	sockopt_params;
+
+
+    /**
+     * Intial timeout interval to be applied to incoming transports 
+     * (i.e. server side) when no data received after a successful connection.
+     *
+     * Default: PJSIP_TCP_INITIAL_TIMEOUT
+     */
+    unsigned		initial_timeout;
 
 } pjsip_tcp_transport_cfg;
Index: pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c	(revision 5868)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c	(revision 5869)
@@ -64,4 +64,5 @@
     pj_bool_t		     reuse_addr;        
     unsigned		     async_cnt;    
+    unsigned		     initial_timeout;
 
     /* Group lock to be used by TCP listener and ioqueue key */
@@ -124,4 +125,7 @@
     /* Group lock to be used by TCP transport and ioqueue key */
     pj_grp_lock_t	    *grp_lock;
+
+    /* Initial timer. */
+    pj_timer_entry	     initial_timer;
 };
 
@@ -237,4 +241,5 @@
     cfg->async_cnt = 1;
     cfg->reuse_addr = PJSIP_TCP_TRANSPORT_REUSEADDR;
+    cfg->initial_timeout = PJSIP_TCP_INITIAL_TIMEOUT;
 }
 
@@ -392,4 +397,5 @@
     listener->reuse_addr = cfg->reuse_addr;
     listener->async_cnt = cfg->async_cnt;
+    listener->initial_timeout = cfg->initial_timeout;
     pj_memcpy(&listener->qos_params, &cfg->qos_params,
 	      sizeof(cfg->qos_params));
@@ -594,4 +600,7 @@
 /* TCP keep-alive timer callback */
 static void tcp_keep_alive_timer(pj_timer_heap_t *th, pj_timer_entry *e);
+
+/* TCP initial timer callback */
+static void tcp_initial_timer(pj_timer_heap_t *th, pj_timer_entry *e);
 
 /* Clean up TCP resources */
@@ -715,4 +724,17 @@
     pj_strdup(tcp->base.pool, &tcp->ka_pkt, &ka_pkt);
 
+    /* Initialize initial timer. */
+    if (is_server && listener->initial_timeout) {
+	tcp->initial_timer.user_data = (void*)tcp;
+	tcp->initial_timer.cb = &tcp_initial_timer;
+
+	pj_time_val delay = { 0 };
+	delay.sec = listener->initial_timeout;
+	pjsip_endpt_schedule_timer(listener->endpt, 
+				    &tcp->initial_timer, 
+				    &delay);
+	tcp->initial_timer.id = PJ_TRUE;
+    }
+
     /* Done setting up basic transport. */
     *p_tcp = tcp;
@@ -810,4 +832,10 @@
 	pjsip_endpt_cancel_timer(tcp->base.endpt, &tcp->ka_timer);
 	tcp->ka_timer.id = PJ_FALSE;
+    }
+
+    /* Stop initial timer. */
+    if (tcp->initial_timer.id) {
+	pjsip_endpt_cancel_timer(tcp->base.endpt, &tcp->initial_timer);
+	tcp->initial_timer.id = PJ_FALSE;
     }
 
@@ -1340,4 +1368,10 @@
     }
 
+    /* Stop initial timer. */
+    if (tcp->initial_timer.id) {
+	pjsip_endpt_cancel_timer(tcp->base.endpt, &tcp->initial_timer);
+	tcp->initial_timer.id = PJ_FALSE;
+    }
+
     return PJ_SUCCESS;
 }
@@ -1366,4 +1400,9 @@
 	tcp->is_closing++;
 	return PJ_FALSE;
+    }
+
+    if (tcp->initial_timer.id) {
+	pjsip_endpt_cancel_timer(tcp->base.endpt, &tcp->initial_timer);
+	tcp->initial_timer.id = PJ_FALSE;
     }
 
@@ -1585,4 +1624,14 @@
 }
 
+/* Transport keep-alive timer callback */
+static void tcp_initial_timer(pj_timer_heap_t *th, pj_timer_entry *e)
+{
+    pj_status_t status = PJ_ETIMEDOUT;
+    struct tcp_transport *tcp = (struct tcp_transport*) e->user_data;
+
+    PJ_UNUSED_ARG(th);
+
+    tcp_init_shutdown(tcp, status);
+}
 
 PJ_DEF(pj_sock_t) pjsip_tcp_transport_get_socket(pjsip_transport *transport)
