summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/include/pj/ssl_sock.h8
-rw-r--r--pjlib/src/pj/ssl_sock_ossl.c12
2 files changed, 20 insertions, 0 deletions
diff --git a/pjlib/include/pj/ssl_sock.h b/pjlib/include/pj/ssl_sock.h
index 534c9144..bfad5af2 100644
--- a/pjlib/include/pj/ssl_sock.h
+++ b/pjlib/include/pj/ssl_sock.h
@@ -711,6 +711,14 @@ typedef struct pj_ssl_sock_param
pj_str_t server_name;
/**
+ * 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
* field rather than \a qos_param fields since this is more portable.
diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c
index b774c674..b5098d22 100644
--- a/pjlib/src/pj/ssl_sock_ossl.c
+++ b/pjlib/src/pj/ssl_sock_ossl.c
@@ -2377,6 +2377,18 @@ PJ_DEF(pj_status_t) pj_ssl_sock_start_accept (pj_ssl_sock_t *ssock,
if (status != PJ_SUCCESS)
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,
&ssock->param.qos_params, 2,