Index: /pjproject/trunk/pjlib/include/pj/ssl_sock.h
===================================================================
--- /pjproject/trunk/pjlib/include/pj/ssl_sock.h	(revision 4505)
+++ /pjproject/trunk/pjlib/include/pj/ssl_sock.h	(revision 4506)
@@ -712,4 +712,12 @@
 
     /**
+     * Specify if SO_REUSEADDR should be used for listening socket. This
+     * option will only be used with accept() operation.
+     *
+     * Default is PJ_FALSE.
+     */
+    pj_bool_t reuse_addr;
+
+    /**
      * QoS traffic type to be set on this transport. When application wants
      * to apply QoS tagging to the transport, it's preferable to set this
Index: /pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
===================================================================
--- /pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c	(revision 4505)
+++ /pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c	(revision 4506)
@@ -2378,4 +2378,16 @@
 	goto on_error;
 
+    /* Apply SO_REUSEADDR */
+    if (ssock->param.reuse_addr) {
+	int enabled = 1;
+	status = pj_sock_setsockopt(ssock->sock, pj_SOL_SOCKET(),
+				    pj_SO_REUSEADDR(),
+				    &enabled, sizeof(enabled));
+	if (status != PJ_SUCCESS) {
+	    PJ_PERROR(4,(ssock->pool->obj_name, status,
+		         "Warning: error applying SO_REUSEADDR"));
+	}
+    }
+
     /* Apply QoS, if specified */
     status = pj_sock_apply_qos2(ssock->sock, ssock->param.qos_type,
Index: /pjproject/trunk/pjsip/include/pjsip/sip_config.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsip/sip_config.h	(revision 4505)
+++ /pjproject/trunk/pjsip/include/pjsip/sip_config.h	(revision 4506)
@@ -570,4 +570,22 @@
 
 /**
+ * Specify whether TCP listener should use SO_REUSEADDR option. This constant
+ * will be used as the default value for the "reuse_addr" field in the
+ * pjsip_tcp_transport_cfg structure.
+ *
+ * Default is FALSE on Windows and TRUE on non-Windows.
+ *
+ * @see PJSIP_TLS_TRANSPORT_REUSEADDR
+ */
+#ifndef PJSIP_TCP_TRANSPORT_REUSEADDR
+# if defined(PJ_WIN32) && PJ_WIN32
+#   define PJSIP_TCP_TRANSPORT_REUSEADDR	0
+# else
+#   define PJSIP_TCP_TRANSPORT_REUSEADDR	1
+# endif
+#endif
+
+
+/**
  * Set the interval to send keep-alive packet for TCP transports.
  * If the value is zero, keep-alive will be disabled for TCP.
@@ -676,4 +694,19 @@
 #endif
 
+
+/**
+ * Specify whether TLS listener should use SO_REUSEADDR option.
+ *
+ * Default is FALSE on Windows and TRUE on non-Windows.
+ *
+ * @see PJSIP_TCP_TRANSPORT_REUSEADDR
+ */
+#ifndef PJSIP_TLS_TRANSPORT_REUSEADDR
+# if defined(PJ_WIN32) && PJ_WIN32
+#   define PJSIP_TLS_TRANSPORT_REUSEADDR	0
+# else
+#   define PJSIP_TLS_TRANSPORT_REUSEADDR	1
+# endif
+#endif
 
 
Index: /pjproject/trunk/pjsip/include/pjsip/sip_transport_tcp.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsip/sip_transport_tcp.h	(revision 4505)
+++ /pjproject/trunk/pjsip/include/pjsip/sip_transport_tcp.h	(revision 4506)
@@ -63,4 +63,10 @@
      */
     pj_sockaddr		bind_addr;
+
+    /**
+     * Should SO_REUSEADDR be used for the listener socket.
+     * Default value is PJSIP_TCP_TRANSPORT_REUSEADDR.
+     */
+    pj_bool_t		reuse_addr;
 
     /**
Index: /pjproject/trunk/pjsip/include/pjsip/sip_transport_tls.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsip/sip_transport_tls.h	(revision 4505)
+++ /pjproject/trunk/pjsip/include/pjsip/sip_transport_tls.h	(revision 4506)
@@ -175,4 +175,10 @@
 
     /**
+     * Should SO_REUSEADDR be used for the listener socket.
+     * Default value is PJSIP_TLS_TRANSPORT_REUSEADDR.
+     */
+    pj_bool_t reuse_addr;
+
+    /**
      * QoS traffic type to be set on this transport. When application wants
      * to apply QoS tagging to the transport, it's preferable to set this
@@ -226,4 +232,5 @@
 {
     pj_memset(tls_opt, 0, sizeof(*tls_opt));
+    tls_opt->reuse_addr = PJSIP_TLS_TRANSPORT_REUSEADDR;
     tls_opt->qos_type = PJ_QOS_TYPE_BEST_EFFORT;
     tls_opt->qos_ignore_error = PJ_TRUE;
Index: /pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c	(revision 4505)
+++ /pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c	(revision 4506)
@@ -218,4 +218,5 @@
     pj_sockaddr_init(cfg->af, &cfg->bind_addr, NULL, 0);
     cfg->async_cnt = 1;
+    cfg->reuse_addr = PJSIP_TCP_TRANSPORT_REUSEADDR;
 }
 
@@ -298,4 +299,15 @@
 				2, listener->factory.obj_name, 
 				"SIP TCP listener socket");
+
+    /* Apply SO_REUSEADDR */
+    if (cfg->reuse_addr) {
+	int enabled = 1;
+	status = pj_sock_setsockopt(sock, pj_SOL_SOCKET(), pj_SO_REUSEADDR(),
+				    &enabled, sizeof(enabled));
+	if (status != PJ_SUCCESS) {
+	    PJ_PERROR(4,(listener->factory.obj_name, status,
+		         "Warning: error applying SO_REUSEADDR"));
+	}
+    }
 
     /* Bind address may be different than factory.local_addr because
Index: /pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c	(revision 4505)
+++ /pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c	(revision 4506)
@@ -338,4 +338,5 @@
     ssock_param.ciphers_num = listener->tls_setting.ciphers_num;
     ssock_param.ciphers = listener->tls_setting.ciphers;
+    ssock_param.reuse_addr = listener->tls_setting.reuse_addr;
     ssock_param.qos_type = listener->tls_setting.qos_type;
     ssock_param.qos_ignore_error = listener->tls_setting.qos_ignore_error;
