Skip to content

Commit

Permalink
Merge pull request #1561 from bluca/sockopt_runtime
Browse files Browse the repository at this point in the history
Problem: zsock options could be available at build time but not at runtime
  • Loading branch information
c-rack authored Nov 20, 2016
2 parents 7249ac5 + 21de525 commit 51a29d5
Show file tree
Hide file tree
Showing 18 changed files with 1,801 additions and 1,660 deletions.
46 changes: 27 additions & 19 deletions api/zsock_option.api
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
******************************************************************
-->

<!-- The following socket options are available in libzmq from version 4.2.0 -->

<method name = "heartbeat ivl" polymorphic = "1">
Get socket option `heartbeat_ivl`.
<return type = "integer" fresh = "1" />
Expand Down Expand Up @@ -153,6 +155,8 @@
<argument name = "vmci connect timeout" type = "integer" />
</method>

<!-- The following socket options are available in libzmq from version 4.1.0 -->

<method name = "tos" polymorphic = "1">
Get socket option `tos`.
<return type = "integer" fresh = "1" />
Expand Down Expand Up @@ -203,6 +207,8 @@
<argument name = "xpub nodrop" type = "integer" />
</method>

<!-- The following socket options are available in libzmq from version 4.0.0 -->

<method name = "set router mandatory" polymorphic = "1">
Set socket option `router_mandatory`.
<argument name = "router mandatory" type = "integer" />
Expand Down Expand Up @@ -388,25 +394,7 @@
<argument name = "immediate" type = "integer" />
</method>

<method name = "set router raw" polymorphic = "1">
Set socket option `router_raw`.
<argument name = "router raw" type = "integer" />
</method>

<method name = "ipv4only" polymorphic = "1">
Get socket option `ipv4only`.
<return type = "integer" fresh = "1" />
</method>

<method name = "set ipv4only" polymorphic = "1">
Set socket option `ipv4only`.
<argument name = "ipv4only" type = "integer" />
</method>

<method name = "set delay attach on connect" polymorphic = "1">
Set socket option `delay_attach_on_connect`.
<argument name = "delay attach on connect" type = "integer" />
</method>
<!-- The following socket options are available in libzmq from version 3.0.0 -->

<method name = "type" polymorphic = "1">
Get socket option `type`.
Expand Down Expand Up @@ -657,3 +645,23 @@
Get socket option `last_endpoint`.
<return type = "string" fresh = "1" />
</method>

<method name = "set router raw" polymorphic = "1">
Set socket option `router_raw`.
<argument name = "router raw" type = "integer" />
</method>

<method name = "ipv4only" polymorphic = "1">
Get socket option `ipv4only`.
<return type = "integer" fresh = "1" />
</method>

<method name = "set ipv4only" polymorphic = "1">
Set socket option `ipv4only`.
<argument name = "ipv4only" type = "integer" />
</method>

<method name = "set delay attach on connect" polymorphic = "1">
Set socket option `delay_attach_on_connect`.
<argument name = "delay attach on connect" type = "integer" />
</method>
50 changes: 25 additions & 25 deletions bindings/jni/src/main/c/org_zeromq_czmq_Zsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,31 +892,6 @@ Java_org_zeromq_czmq_Zsock__1_1setImmediate (JNIEnv *env, jclass c, jlong self,
zsock_set_immediate ((zsock_t *) (intptr_t) self, (int) immediate);
}

JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Zsock__1_1setRouterRaw (JNIEnv *env, jclass c, jlong self, jint router_raw)
{
zsock_set_router_raw ((zsock_t *) (intptr_t) self, (int) router_raw);
}

JNIEXPORT jint JNICALL
Java_org_zeromq_czmq_Zsock__1_1ipv4only (JNIEnv *env, jclass c, jlong self)
{
jint ipv4only_ = (jint) zsock_ipv4only ((zsock_t *) (intptr_t) self);
return ipv4only_;
}

JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Zsock__1_1setIpv4only (JNIEnv *env, jclass c, jlong self, jint ipv4only)
{
zsock_set_ipv4only ((zsock_t *) (intptr_t) self, (int) ipv4only);
}

JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Zsock__1_1setDelayAttachOnConnect (JNIEnv *env, jclass c, jlong self, jint delay_attach_on_connect)
{
zsock_set_delay_attach_on_connect ((zsock_t *) (intptr_t) self, (int) delay_attach_on_connect);
}

JNIEXPORT jint JNICALL
Java_org_zeromq_czmq_Zsock__1_1type (JNIEnv *env, jclass c, jlong self)
{
Expand Down Expand Up @@ -1250,6 +1225,31 @@ Java_org_zeromq_czmq_Zsock__1_1lastEndpoint (JNIEnv *env, jclass c, jlong self)
return return_string_;
}

JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Zsock__1_1setRouterRaw (JNIEnv *env, jclass c, jlong self, jint router_raw)
{
zsock_set_router_raw ((zsock_t *) (intptr_t) self, (int) router_raw);
}

JNIEXPORT jint JNICALL
Java_org_zeromq_czmq_Zsock__1_1ipv4only (JNIEnv *env, jclass c, jlong self)
{
jint ipv4only_ = (jint) zsock_ipv4only ((zsock_t *) (intptr_t) self);
return ipv4only_;
}

JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Zsock__1_1setIpv4only (JNIEnv *env, jclass c, jlong self, jint ipv4only)
{
zsock_set_ipv4only ((zsock_t *) (intptr_t) self, (int) ipv4only);
}

JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Zsock__1_1setDelayAttachOnConnect (JNIEnv *env, jclass c, jlong self, jint delay_attach_on_connect)
{
zsock_set_delay_attach_on_connect ((zsock_t *) (intptr_t) self, (int) delay_attach_on_connect);
}

JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Zsock__1_1test (JNIEnv *env, jclass c, jboolean verbose)
{
Expand Down
56 changes: 28 additions & 28 deletions bindings/jni/src/main/java/org/zeromq/czmq/Zsock.java
Original file line number Diff line number Diff line change
Expand Up @@ -977,34 +977,6 @@ public void setImmediate (int immediate) {
__setImmediate (self, immediate);
}
/*
Set socket option `router_raw`.
*/
native static void __setRouterRaw (long self, int routerRaw);
public void setRouterRaw (int routerRaw) {
__setRouterRaw (self, routerRaw);
}
/*
Get socket option `ipv4only`.
*/
native static int __ipv4only (long self);
public int ipv4only () {
return __ipv4only (self);
}
/*
Set socket option `ipv4only`.
*/
native static void __setIpv4only (long self, int ipv4only);
public void setIpv4only (int ipv4only) {
__setIpv4only (self, ipv4only);
}
/*
Set socket option `delay_attach_on_connect`.
*/
native static void __setDelayAttachOnConnect (long self, int delayAttachOnConnect);
public void setDelayAttachOnConnect (int delayAttachOnConnect) {
__setDelayAttachOnConnect (self, delayAttachOnConnect);
}
/*
Get socket option `type`.
*/
native static int __type (long self);
Expand Down Expand Up @@ -1348,6 +1320,34 @@ public String lastEndpoint () {
return __lastEndpoint (self);
}
/*
Set socket option `router_raw`.
*/
native static void __setRouterRaw (long self, int routerRaw);
public void setRouterRaw (int routerRaw) {
__setRouterRaw (self, routerRaw);
}
/*
Get socket option `ipv4only`.
*/
native static int __ipv4only (long self);
public int ipv4only () {
return __ipv4only (self);
}
/*
Set socket option `ipv4only`.
*/
native static void __setIpv4only (long self, int ipv4only);
public void setIpv4only (int ipv4only) {
__setIpv4only (self, ipv4only);
}
/*
Set socket option `delay_attach_on_connect`.
*/
native static void __setDelayAttachOnConnect (long self, int delayAttachOnConnect);
public void setDelayAttachOnConnect (int delayAttachOnConnect) {
__setDelayAttachOnConnect (self, delayAttachOnConnect);
}
/*
Self test of this class.
*/
native static void __test (boolean verbose);
Expand Down
48 changes: 24 additions & 24 deletions bindings/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2867,30 +2867,6 @@ nothing my_zsock.setImmediate (Number)

Set socket option `immediate`.

```
nothing my_zsock.setRouterRaw (Number)
```

Set socket option `router_raw`.

```
integer my_zsock.ipv4only ()
```

Get socket option `ipv4only`.

```
nothing my_zsock.setIpv4only (Number)
```

Set socket option `ipv4only`.

```
nothing my_zsock.setDelayAttachOnConnect (Number)
```

Set socket option `delay_attach_on_connect`.

```
integer my_zsock.type ()
```
Expand Down Expand Up @@ -3185,6 +3161,30 @@ string my_zsock.lastEndpoint ()

Get socket option `last_endpoint`.

```
nothing my_zsock.setRouterRaw (Number)
```

Set socket option `router_raw`.

```
integer my_zsock.ipv4only ()
```

Get socket option `ipv4only`.

```
nothing my_zsock.setIpv4only (Number)
```

Set socket option `ipv4only`.

```
nothing my_zsock.setDelayAttachOnConnect (Number)
```

Set socket option `delay_attach_on_connect`.

```
nothing my_zsock.test (Boolean)
```
Expand Down
98 changes: 49 additions & 49 deletions bindings/nodejs/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4145,10 +4145,6 @@ NAN_MODULE_INIT (Zsock::Init) {
Nan::SetPrototypeMethod (tpl, "setIpv6", _set_ipv6);
Nan::SetPrototypeMethod (tpl, "immediate", _immediate);
Nan::SetPrototypeMethod (tpl, "setImmediate", _set_immediate);
Nan::SetPrototypeMethod (tpl, "setRouterRaw", _set_router_raw);
Nan::SetPrototypeMethod (tpl, "ipv4only", _ipv4only);
Nan::SetPrototypeMethod (tpl, "setIpv4only", _set_ipv4only);
Nan::SetPrototypeMethod (tpl, "setDelayAttachOnConnect", _set_delay_attach_on_connect);
Nan::SetPrototypeMethod (tpl, "type", _type);
Nan::SetPrototypeMethod (tpl, "sndhwm", _sndhwm);
Nan::SetPrototypeMethod (tpl, "setSndhwm", _set_sndhwm);
Expand Down Expand Up @@ -4198,6 +4194,10 @@ NAN_MODULE_INIT (Zsock::Init) {
Nan::SetPrototypeMethod (tpl, "rcvmore", _rcvmore);
Nan::SetPrototypeMethod (tpl, "events", _events);
Nan::SetPrototypeMethod (tpl, "lastEndpoint", _last_endpoint);
Nan::SetPrototypeMethod (tpl, "setRouterRaw", _set_router_raw);
Nan::SetPrototypeMethod (tpl, "ipv4only", _ipv4only);
Nan::SetPrototypeMethod (tpl, "setIpv4only", _set_ipv4only);
Nan::SetPrototypeMethod (tpl, "setDelayAttachOnConnect", _set_delay_attach_on_connect);
Nan::SetPrototypeMethod (tpl, "test", _test);

constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ());
Expand Down Expand Up @@ -5314,51 +5314,6 @@ NAN_METHOD (Zsock::_set_immediate) {
zsock_set_immediate (zsock->self, (int) immediate);
}

NAN_METHOD (Zsock::_set_router_raw) {
Zsock *zsock = Nan::ObjectWrap::Unwrap <Zsock> (info.Holder ());
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `router raw`");

int router_raw;
if (info [0]->IsNumber ())
router_raw = Nan::To<int>(info [0]).FromJust ();
else
return Nan::ThrowTypeError ("`router raw` must be a number");
zsock_set_router_raw (zsock->self, (int) router_raw);
}

NAN_METHOD (Zsock::_ipv4only) {
Zsock *zsock = Nan::ObjectWrap::Unwrap <Zsock> (info.Holder ());
int result = zsock_ipv4only (zsock->self);
info.GetReturnValue ().Set (Nan::New<Number>(result));
}

NAN_METHOD (Zsock::_set_ipv4only) {
Zsock *zsock = Nan::ObjectWrap::Unwrap <Zsock> (info.Holder ());
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `ipv4only`");

int ipv4only;
if (info [0]->IsNumber ())
ipv4only = Nan::To<int>(info [0]).FromJust ();
else
return Nan::ThrowTypeError ("`ipv4only` must be a number");
zsock_set_ipv4only (zsock->self, (int) ipv4only);
}

NAN_METHOD (Zsock::_set_delay_attach_on_connect) {
Zsock *zsock = Nan::ObjectWrap::Unwrap <Zsock> (info.Holder ());
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `delay attach on connect`");

int delay_attach_on_connect;
if (info [0]->IsNumber ())
delay_attach_on_connect = Nan::To<int>(info [0]).FromJust ();
else
return Nan::ThrowTypeError ("`delay attach on connect` must be a number");
zsock_set_delay_attach_on_connect (zsock->self, (int) delay_attach_on_connect);
}

NAN_METHOD (Zsock::_type) {
Zsock *zsock = Nan::ObjectWrap::Unwrap <Zsock> (info.Holder ());
int result = zsock_type (zsock->self);
Expand Down Expand Up @@ -5829,6 +5784,51 @@ NAN_METHOD (Zsock::_last_endpoint) {
info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ());
}

NAN_METHOD (Zsock::_set_router_raw) {
Zsock *zsock = Nan::ObjectWrap::Unwrap <Zsock> (info.Holder ());
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `router raw`");

int router_raw;
if (info [0]->IsNumber ())
router_raw = Nan::To<int>(info [0]).FromJust ();
else
return Nan::ThrowTypeError ("`router raw` must be a number");
zsock_set_router_raw (zsock->self, (int) router_raw);
}

NAN_METHOD (Zsock::_ipv4only) {
Zsock *zsock = Nan::ObjectWrap::Unwrap <Zsock> (info.Holder ());
int result = zsock_ipv4only (zsock->self);
info.GetReturnValue ().Set (Nan::New<Number>(result));
}

NAN_METHOD (Zsock::_set_ipv4only) {
Zsock *zsock = Nan::ObjectWrap::Unwrap <Zsock> (info.Holder ());
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `ipv4only`");

int ipv4only;
if (info [0]->IsNumber ())
ipv4only = Nan::To<int>(info [0]).FromJust ();
else
return Nan::ThrowTypeError ("`ipv4only` must be a number");
zsock_set_ipv4only (zsock->self, (int) ipv4only);
}

NAN_METHOD (Zsock::_set_delay_attach_on_connect) {
Zsock *zsock = Nan::ObjectWrap::Unwrap <Zsock> (info.Holder ());
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `delay attach on connect`");

int delay_attach_on_connect;
if (info [0]->IsNumber ())
delay_attach_on_connect = Nan::To<int>(info [0]).FromJust ();
else
return Nan::ThrowTypeError ("`delay attach on connect` must be a number");
zsock_set_delay_attach_on_connect (zsock->self, (int) delay_attach_on_connect);
}

NAN_METHOD (Zsock::_test) {
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `verbose`");
Expand Down
Loading

0 comments on commit 51a29d5

Please sign in to comment.